Esempio n. 1
0
 def get(self, request, *args, **kwargs):
     orders_page = create_paginated_page(
         query_set=Order.objects.filter(user=request.user).order_by("-id"),
         page_number=request.GET.get("page") or 1,
         objects_per_page=ORDERS_PER_PAGE,
     )
     return self.render_to_response({"orders_page": orders_page})
Esempio n. 2
0
 def get(self, request):
     accounts_page = create_paginated_page(
         query_set=Account.objects.filter(user=request.user).order_by('-id'),
         page_number=request.GET.get('page') or 1,
         objects_per_page=ACCOUNTS_PER_PAGE
     )
     return self.render_to_response({'accounts_page': accounts_page })
Esempio n. 3
0
    def get(self, request, *args, **kwargs):
        account_uid = int(kwargs.get('account_uid', -1))
        account = get_object_or_404(Account, uid=account_uid)

        transactions_page = create_paginated_page(
            query_set=Transaction.objects.filter(account=account).order_by('-created'),
            page_number=request.GET.get('page') or 1,
            objects_per_page=TRANSACTIONS_PER_PAGE
        )
        return self.render_to_response({'transactions_page': transactions_page})
Esempio n. 4
0
    def get(self, request, *args, **kwargs):
        account_uid = int(kwargs.get("account_uid", -1))
        account = get_object_or_404(Account, uid=account_uid)

        invoices_page = create_paginated_page(
            query_set=account.invoices.all().order_by("-created"),
            page_number=request.GET.get("page") or 1,
            objects_per_page=INVOICES_PER_PAGE,
        )
        return self.render_to_response({"invoices_page": invoices_page})
Esempio n. 5
0
 def test_wrong_page_number(self):
     page = create_paginated_page(query_set=self.objects, page_number='JDJDJD', objects_per_page=self.OBJECTS_PER_PAGE)
     self.assertEqual(self.PAGE_NUMBER, page.number)
Esempio n. 6
0
 def test_create_paginator(self):
     page = create_paginated_page(query_set=self.objects, page_number=self.PAGE_NUMBER, objects_per_page=self.OBJECTS_PER_PAGE)
     self.assertEqual(len(self.objects), page.paginator.count)
     self.assertEqual(self.PAGE_NUMBER, page.number)