Skip to content
This repository has been archived by the owner on Feb 28, 2020. It is now read-only.

Commit

Permalink
compatibility layer for DRF 3.0, fixes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Feb 6, 2015
1 parent fd772c9 commit c9f2c90
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions stored_messages/compat.py
Expand Up @@ -19,3 +19,9 @@
except ImportError:
from django.contrib.auth.models import User
get_user_model = lambda: User

# DRF 3.0 compatibility layer
try:
from rest_framework.decorators import action as detail_route
except ImportError:
from rest_framework.decorators import detail_route
2 changes: 1 addition & 1 deletion stored_messages/serializers.py
Expand Up @@ -6,4 +6,4 @@ class InboxSerializer(serializers.Serializer):
message = serializers.CharField()
level = serializers.IntegerField()
tags = serializers.CharField()
date = serializers.DateTimeField()
date = serializers.DateTimeField(format=None)
6 changes: 3 additions & 3 deletions stored_messages/views.py
@@ -1,12 +1,12 @@
from rest_framework import viewsets
from rest_framework.decorators import action, api_view
from rest_framework.decorators import api_view
from rest_framework.response import Response

from django.contrib.auth.decorators import login_required

from .serializers import InboxSerializer
from .backends.exceptions import MessageDoesNotExist

from .compat import detail_route


class InboxViewSet(viewsets.ViewSet):
Expand All @@ -33,7 +33,7 @@ def retrieve(self, request, pk=None):
serializer = InboxSerializer(msg, many=False)
return Response(serializer.data)

@action()
@detail_route(methods=['POST'])
def read(self, request, pk=None):
"""
Mark the message as read (i.e. delete from inbox)
Expand Down

0 comments on commit c9f2c90

Please sign in to comment.