mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-25 10:08:36 +02:00
Apply CustomNumberPagination to all API views
This commit is contained in:
@@ -433,8 +433,7 @@ REST_FRAMEWORK = {
|
|||||||
"apps.api.permissions.NotInDemoMode",
|
"apps.api.permissions.NotInDemoMode",
|
||||||
"rest_framework.permissions.DjangoModelPermissions",
|
"rest_framework.permissions.DjangoModelPermissions",
|
||||||
],
|
],
|
||||||
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
|
"DEFAULT_PAGINATION_CLASS": "apps.api.custom.pagination.CustomPageNumberPagination",
|
||||||
"PAGE_SIZE": 10,
|
|
||||||
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
|
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ from rest_framework.response import Response
|
|||||||
|
|
||||||
from apps.accounts.models import AccountGroup, Account
|
from apps.accounts.models import AccountGroup, Account
|
||||||
from apps.accounts.services import get_account_balance
|
from apps.accounts.services import get_account_balance
|
||||||
from apps.api.custom.pagination import CustomPageNumberPagination
|
|
||||||
from apps.api.serializers import AccountGroupSerializer, AccountSerializer, AccountBalanceSerializer
|
from apps.api.serializers import AccountGroupSerializer, AccountSerializer, AccountBalanceSerializer
|
||||||
|
|
||||||
|
|
||||||
@@ -15,7 +14,6 @@ class AccountGroupViewSet(viewsets.ModelViewSet):
|
|||||||
|
|
||||||
queryset = AccountGroup.objects.all()
|
queryset = AccountGroup.objects.all()
|
||||||
serializer_class = AccountGroupSerializer
|
serializer_class = AccountGroupSerializer
|
||||||
pagination_class = CustomPageNumberPagination
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return AccountGroup.objects.all().order_by("id")
|
return AccountGroup.objects.all().order_by("id")
|
||||||
@@ -33,7 +31,6 @@ class AccountViewSet(viewsets.ModelViewSet):
|
|||||||
|
|
||||||
queryset = Account.objects.all()
|
queryset = Account.objects.all()
|
||||||
serializer_class = AccountSerializer
|
serializer_class = AccountSerializer
|
||||||
pagination_class = CustomPageNumberPagination
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ from copy import deepcopy
|
|||||||
|
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
|
|
||||||
from apps.api.custom.pagination import CustomPageNumberPagination
|
|
||||||
from apps.api.serializers import (
|
from apps.api.serializers import (
|
||||||
TransactionSerializer,
|
TransactionSerializer,
|
||||||
TransactionCategorySerializer,
|
TransactionCategorySerializer,
|
||||||
@@ -25,7 +24,6 @@ from apps.rules.signals import transaction_updated, transaction_created
|
|||||||
class TransactionViewSet(viewsets.ModelViewSet):
|
class TransactionViewSet(viewsets.ModelViewSet):
|
||||||
queryset = Transaction.objects.all()
|
queryset = Transaction.objects.all()
|
||||||
serializer_class = TransactionSerializer
|
serializer_class = TransactionSerializer
|
||||||
pagination_class = CustomPageNumberPagination
|
|
||||||
|
|
||||||
def perform_create(self, serializer):
|
def perform_create(self, serializer):
|
||||||
instance = serializer.save()
|
instance = serializer.save()
|
||||||
@@ -47,7 +45,6 @@ class TransactionViewSet(viewsets.ModelViewSet):
|
|||||||
class TransactionCategoryViewSet(viewsets.ModelViewSet):
|
class TransactionCategoryViewSet(viewsets.ModelViewSet):
|
||||||
queryset = TransactionCategory.objects.all()
|
queryset = TransactionCategory.objects.all()
|
||||||
serializer_class = TransactionCategorySerializer
|
serializer_class = TransactionCategorySerializer
|
||||||
pagination_class = CustomPageNumberPagination
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return TransactionCategory.objects.all().order_by("id")
|
return TransactionCategory.objects.all().order_by("id")
|
||||||
@@ -56,7 +53,6 @@ class TransactionCategoryViewSet(viewsets.ModelViewSet):
|
|||||||
class TransactionTagViewSet(viewsets.ModelViewSet):
|
class TransactionTagViewSet(viewsets.ModelViewSet):
|
||||||
queryset = TransactionTag.objects.all()
|
queryset = TransactionTag.objects.all()
|
||||||
serializer_class = TransactionTagSerializer
|
serializer_class = TransactionTagSerializer
|
||||||
pagination_class = CustomPageNumberPagination
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return TransactionTag.objects.all().order_by("id")
|
return TransactionTag.objects.all().order_by("id")
|
||||||
@@ -65,7 +61,6 @@ class TransactionTagViewSet(viewsets.ModelViewSet):
|
|||||||
class TransactionEntityViewSet(viewsets.ModelViewSet):
|
class TransactionEntityViewSet(viewsets.ModelViewSet):
|
||||||
queryset = TransactionEntity.objects.all()
|
queryset = TransactionEntity.objects.all()
|
||||||
serializer_class = TransactionEntitySerializer
|
serializer_class = TransactionEntitySerializer
|
||||||
pagination_class = CustomPageNumberPagination
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return TransactionEntity.objects.all().order_by("id")
|
return TransactionEntity.objects.all().order_by("id")
|
||||||
@@ -74,7 +69,6 @@ class TransactionEntityViewSet(viewsets.ModelViewSet):
|
|||||||
class InstallmentPlanViewSet(viewsets.ModelViewSet):
|
class InstallmentPlanViewSet(viewsets.ModelViewSet):
|
||||||
queryset = InstallmentPlan.objects.all()
|
queryset = InstallmentPlan.objects.all()
|
||||||
serializer_class = InstallmentPlanSerializer
|
serializer_class = InstallmentPlanSerializer
|
||||||
pagination_class = CustomPageNumberPagination
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return InstallmentPlan.objects.all().order_by("-id")
|
return InstallmentPlan.objects.all().order_by("-id")
|
||||||
@@ -83,7 +77,6 @@ class InstallmentPlanViewSet(viewsets.ModelViewSet):
|
|||||||
class RecurringTransactionViewSet(viewsets.ModelViewSet):
|
class RecurringTransactionViewSet(viewsets.ModelViewSet):
|
||||||
queryset = RecurringTransaction.objects.all()
|
queryset = RecurringTransaction.objects.all()
|
||||||
serializer_class = RecurringTransactionSerializer
|
serializer_class = RecurringTransactionSerializer
|
||||||
pagination_class = CustomPageNumberPagination
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return RecurringTransaction.objects.all().order_by("-id")
|
return RecurringTransaction.objects.all().order_by("-id")
|
||||||
|
|||||||
Reference in New Issue
Block a user