fix organization pagination - quota distribution
This commit is contained in:
@@ -12,6 +12,7 @@ from apps.authentication.api.v1.serializers.serializer import (
|
||||
BankAccountSerializer,
|
||||
)
|
||||
from rest_framework_simplejwt.views import TokenObtainPairView
|
||||
from apps.core.pagination import CustomPageNumberPagination
|
||||
from apps.authorization.api.v1 import api as authorize_view
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from apps.authentication.tools import get_token_jti
|
||||
@@ -221,17 +222,21 @@ class OrganizationViewSet(ModelViewSet):
|
||||
detail=False,
|
||||
url_path='organizations_by_province',
|
||||
url_name='organizations_by_province',
|
||||
name='organizations_by_province'
|
||||
name='organizations_by_province',
|
||||
)
|
||||
@transaction.atomic
|
||||
def get_organizations_by_province(self, request):
|
||||
""" list of organizations by province """
|
||||
|
||||
serializer = self.serializer_class(
|
||||
self.queryset.filter(
|
||||
province=int(request.GET['province'])),
|
||||
many=True
|
||||
)
|
||||
queryset = self.queryset.filter(province=int(request.GET['province']))
|
||||
|
||||
page = self.paginate_queryset(queryset) # paginate queryset
|
||||
|
||||
if page is not None:
|
||||
serializer = self.serializer_class(page, many=True)
|
||||
return self.get_paginated_response(serializer.data)
|
||||
|
||||
serializer = self.serializer_class(queryset, many=True)
|
||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user