mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-07-13 16:22:42 +02:00
Merge pull request #497 from icovada/pagination_simplification
refactor(api): apply CustomNumberPagination to all API views
This commit is contained in:
@@ -443,8 +443,7 @@ REST_FRAMEWORK = {
|
|||||||
'rest_framework.authentication.SessionAuthentication',
|
'rest_framework.authentication.SessionAuthentication',
|
||||||
'rest_framework.authentication.TokenAuthentication',
|
'rest_framework.authentication.TokenAuthentication',
|
||||||
],
|
],
|
||||||
"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 (
|
from apps.api.serializers import (
|
||||||
AccountGroupSerializer,
|
AccountGroupSerializer,
|
||||||
AccountSerializer,
|
AccountSerializer,
|
||||||
@@ -19,7 +18,6 @@ class AccountGroupViewSet(viewsets.ModelViewSet):
|
|||||||
|
|
||||||
queryset = AccountGroup.objects.all()
|
queryset = AccountGroup.objects.all()
|
||||||
serializer_class = AccountGroupSerializer
|
serializer_class = AccountGroupSerializer
|
||||||
pagination_class = CustomPageNumberPagination
|
|
||||||
filterset_fields = {
|
filterset_fields = {
|
||||||
"name": ["exact", "icontains"],
|
"name": ["exact", "icontains"],
|
||||||
"owner": ["exact"],
|
"owner": ["exact"],
|
||||||
@@ -44,7 +42,6 @@ class AccountViewSet(viewsets.ModelViewSet):
|
|||||||
|
|
||||||
queryset = Account.objects.all()
|
queryset = Account.objects.all()
|
||||||
serializer_class = AccountSerializer
|
serializer_class = AccountSerializer
|
||||||
pagination_class = CustomPageNumberPagination
|
|
||||||
filterset_fields = {
|
filterset_fields = {
|
||||||
"name": ["exact", "icontains"],
|
"name": ["exact", "icontains"],
|
||||||
"group": ["exact", "isnull"],
|
"group": ["exact", "isnull"],
|
||||||
|
|||||||
@@ -22,9 +22,6 @@ class DCAStrategyViewSet(viewsets.ModelViewSet):
|
|||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return DCAStrategy.objects.all()
|
return DCAStrategy.objects.all()
|
||||||
|
|
||||||
def get_queryset(self):
|
|
||||||
return DCAStrategy.objects.all().order_by("id")
|
|
||||||
|
|
||||||
@action(detail=True, methods=["get"])
|
@action(detail=True, methods=["get"])
|
||||||
def investment_frequency(self, request, pk=None):
|
def investment_frequency(self, request, pk=None):
|
||||||
strategy = self.get_object()
|
strategy = self.get_object()
|
||||||
|
|||||||
@@ -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
|
|
||||||
filterset_fields = {
|
filterset_fields = {
|
||||||
"account": ["exact"],
|
"account": ["exact"],
|
||||||
"type": ["exact"],
|
"type": ["exact"],
|
||||||
@@ -72,7 +70,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
|
|
||||||
filterset_fields = {
|
filterset_fields = {
|
||||||
"name": ["exact", "icontains"],
|
"name": ["exact", "icontains"],
|
||||||
"mute": ["exact"],
|
"mute": ["exact"],
|
||||||
@@ -90,7 +87,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
|
|
||||||
filterset_fields = {
|
filterset_fields = {
|
||||||
"name": ["exact", "icontains"],
|
"name": ["exact", "icontains"],
|
||||||
"active": ["exact"],
|
"active": ["exact"],
|
||||||
@@ -107,7 +103,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
|
|
||||||
filterset_fields = {
|
filterset_fields = {
|
||||||
"name": ["exact", "icontains"],
|
"name": ["exact", "icontains"],
|
||||||
"active": ["exact"],
|
"active": ["exact"],
|
||||||
@@ -124,7 +119,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
|
|
||||||
filterset_fields = {
|
filterset_fields = {
|
||||||
"account": ["exact"],
|
"account": ["exact"],
|
||||||
"type": ["exact"],
|
"type": ["exact"],
|
||||||
@@ -153,7 +147,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
|
|
||||||
filterset_fields = {
|
filterset_fields = {
|
||||||
"is_paused": ["exact"],
|
"is_paused": ["exact"],
|
||||||
"account": ["exact"],
|
"account": ["exact"],
|
||||||
|
|||||||
Reference in New Issue
Block a user