Skip to content

Commit

Permalink
Use request from instance.
Browse files Browse the repository at this point in the history
  • Loading branch information
olmar committed Dec 2, 2014
1 parent ee1dec2 commit 440e47f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions notesapi/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class AnnotationSearchView(APIView):
"""
permission_classes = (AllowAny,)

def get(self, request, *args, **kwargs):
def get(self, *args, **kwargs):
"""
Search annotations.
This method supports the limit and offset query parameters for paging
through results.
"""
params = request.QUERY_PARAMS.dict()
params = self.request.QUERY_PARAMS.dict()

if 'offset' in params:
kwargs['offset'] = _convert_to_int(params.pop('offset'))
Expand Down Expand Up @@ -57,26 +57,26 @@ class AnnotationListView(APIView):
"""
permission_classes = (AllowAny,)

def get(self, request, *args, **kwargs):
def get(self, *args, **kwargs):
"""
Get a list of all annotations.
"""
kwargs['query'] = request.QUERY_PARAMS.dict()
self.kwargs['query'] = self.request.QUERY_PARAMS.dict()

annotations = Annotation.search(**kwargs)

return Response(annotations)

def post(self, request, *args, **kwargs):
def post(self, *args, **kwargs):
"""
Create a new annotation.
Returns 400 request if bad payload is sent or it was empty object.
"""
if 'id' in request.DATA:
if 'id' in self.request.DATA:
return Response(status=status.HTTP_400_BAD_REQUEST)

filtered_payload = _filter_input(request.DATA, CREATE_FILTER_FIELDS)
filtered_payload = _filter_input(self.request.DATA, CREATE_FILTER_FIELDS)

if len(filtered_payload) == 0:
return Response(status=status.HTTP_400_BAD_REQUEST)
Expand All @@ -97,7 +97,7 @@ class AnnotationDetailView(APIView):

UPDATE_FILTER_FIELDS = ('updated', 'created', 'user', 'consumer')

def get(self, request, *args, **kwargs):
def get(self, *args, **kwargs):
"""
Get an existing annotation.
"""
Expand All @@ -109,7 +109,7 @@ def get(self, request, *args, **kwargs):

return Response(annotation)

def put(self, request, *args, **kwargs):
def put(self, *args, **kwargs):
"""
Update an existing annotation.
"""
Expand All @@ -119,8 +119,8 @@ def put(self, request, *args, **kwargs):
if not annotation:
return Response('Annotation not found! No update performed.', status=status.HTTP_404_NOT_FOUND)

if request.DATA is not None:
updated = _filter_input(request.DATA, UPDATE_FILTER_FIELDS)
if self.request.DATA is not None:
updated = _filter_input(self.request.DATA, UPDATE_FILTER_FIELDS)
updated['id'] = annotation_id # use id from URL, regardless of what arrives in JSON payload.

annotation.update(updated)
Expand All @@ -130,7 +130,7 @@ def put(self, request, *args, **kwargs):

return Response(annotation)

def delete(self, request, *args, **kwargs):
def delete(self, *args, **kwargs):
"""
Delete an annotation.
"""
Expand Down
2 changes: 1 addition & 1 deletion notesserver/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class StatusView(APIView):
"""
permission_classes = (AllowAny,)

def get(self, request):
def get(self, *args, **kwargs):
"""
Service status.
"""
Expand Down

0 comments on commit 440e47f

Please sign in to comment.