Skip to content

Commit b3b0ced

Browse files
authored
388 - Paginated wallets (#389)
1 parent fb450fa commit b3b0ced

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

thenewboston/wallets/filters/__init__.py

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import django_filters
2+
3+
from ..models import Wallet
4+
5+
6+
class WalletFilter(django_filters.FilterSet):
7+
currency = django_filters.NumberFilter(field_name='currency')
8+
9+
class Meta:
10+
model = Wallet
11+
fields = ('currency',)

thenewboston/wallets/views/wallet.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
from django.conf import settings
2+
from django_filters.rest_framework import DjangoFilterBackend
23
from rest_framework import mixins, status, viewsets
34
from rest_framework.decorators import action
45
from rest_framework.permissions import IsAuthenticated
56
from rest_framework.response import Response
67

78
from thenewboston.api.accounts import fetch_balance, wire_funds
89
from thenewboston.general.constants import TRANSACTION_FEE
10+
from thenewboston.general.pagination import CustomPageNumberPagination
911
from thenewboston.general.permissions import IsObjectOwnerOrReadOnly
1012

13+
from ..filters.wallet import WalletFilter
1114
from ..models import Wallet, Wire
1215
from ..models.wire import WireType
1316
from ..serializers.block import BlockSerializer
@@ -20,6 +23,9 @@
2023
class WalletViewSet(
2124
mixins.CreateModelMixin, mixins.RetrieveModelMixin, mixins.ListModelMixin, viewsets.GenericViewSet
2225
):
26+
filter_backends = [DjangoFilterBackend]
27+
filterset_class = WalletFilter
28+
pagination_class = CustomPageNumberPagination
2329
permission_classes = [IsAuthenticated, IsObjectOwnerOrReadOnly]
2430
queryset = Wallet.objects.none()
2531

0 commit comments

Comments
 (0)