Skip to content

Commit

Permalink
Use the "CountOverridablePageNumberPagination" class as the paginator…
Browse files Browse the repository at this point in the history
… for the data viewset
  • Loading branch information
DavisRayM committed Dec 10, 2020
1 parent b2cfd98 commit a62fec9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions onadata/apps/api/viewsets/data_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
AuthenticateHeaderMixin
from onadata.libs.mixins.cache_control_mixin import CacheControlMixin
from onadata.libs.mixins.etags_mixin import ETagsMixin
from onadata.libs.pagination import StandardPageNumberPagination
from onadata.libs.pagination import CountOverridablePageNumberPagination
from onadata.libs.permissions import CAN_DELETE_SUBMISSION, \
filter_queryset_xform_meta_perms, filter_queryset_xform_meta_perms_sql
from onadata.libs.renderers import renderers
Expand Down Expand Up @@ -121,8 +121,9 @@ class DataViewSet(AnonymousUserPublicFormsMixin,
lookup_field = 'pk'
lookup_fields = ('pk', 'dataid')
extra_lookup_fields = None
data_count = None
public_data_endpoint = 'public'
pagination_class = StandardPageNumberPagination
pagination_class = CountOverridablePageNumberPagination

queryset = XForm.objects.filter(deleted_at__isnull=True)

Expand Down Expand Up @@ -534,6 +535,14 @@ def set_object_list(
except DataError as e:
raise ParseError(text(e))

def paginate_queryset(self, queryset):
if self.paginator is None:
return None
return self.paginator.paginate_queryset(queryset,
self.request,
view=self,
count=self.data_count)

def _get_data(self, query, fields, sort, start, limit, is_public_request):
self.set_object_list(
query, fields, sort, start, limit, is_public_request)
Expand Down

0 comments on commit a62fec9

Please sign in to comment.