Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

Commit

Permalink
Implement on-demand pagination with "paginate" query param on each en…
Browse files Browse the repository at this point in the history
…dpoint (default is still no pagination)
  • Loading branch information
aaronstephenson committed Mar 11, 2020
1 parent 81c4f7f commit a567012
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions code.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "liliservices",
"organization": "U.S. Geological Survey",
"description": "Web services for LILI (LIDE (Laboratory for Infectious Disease and the Environment) Information Management System)",
"version": "v1.1.1",
"version": "v1.2.0",
"status": "Production",

"permissions": {
Expand Down Expand Up @@ -47,7 +47,7 @@
},

"date": {
"metadataLastUpdated": "2020-02-18"
"metadataLastUpdated": "2020-023-11"
}
}
]
7 changes: 7 additions & 0 deletions liliapi/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from liliapi.serializers import *
from liliapi.models import *
from liliapi.permissions import *
from liliapi.paginations import *
from liliapi.authentication import *
from liliapi.tasks import *

Expand Down Expand Up @@ -46,13 +47,19 @@ class HistoryViewSet(viewsets.ModelViewSet):
"""

permission_classes = (permissions.IsAuthenticated,)
pagination_class = StandardResultsSetPagination

def perform_create(self, serializer):
serializer.save(created_by=self.request.user, modified_by=self.request.user)

def perform_update(self, serializer):
serializer.save(modified_by=self.request.user)

# override the default pagination to allow disabling of pagination
def paginate_queryset(self, *args, **kwargs):
if self.request and 'paginate' in self.request.query_params:
return super().paginate_queryset(*args, **kwargs)
return None

######
#
Expand Down

0 comments on commit a567012

Please sign in to comment.