From 992622e8d1d3969898d1f8c74f81a8a20a1d39b3 Mon Sep 17 00:00:00 2001 From: Lukas Kucharczyk Date: Fri, 9 Aug 2024 12:23:22 +0200 Subject: [PATCH] make it possible to not use paginator when limit = 0 --- games/purchaseviews.py | 21 ++++-- games/static/base.css | 63 ++++-------------- games/templates/components/simple_table.html | 68 ++++++++++---------- 3 files changed, 64 insertions(+), 88 deletions(-) diff --git a/games/purchaseviews.py b/games/purchaseviews.py index a268d3d..a4fbbbb 100644 --- a/games/purchaseviews.py +++ b/games/purchaseviews.py @@ -15,15 +15,24 @@ from games.views import dateformat @login_required def list_purchases(request: HttpRequest) -> HttpResponse: context: dict[Any, Any] = {} - paginator = Paginator(Purchase.objects.order_by("-date_purchased"), 10) page_number = request.GET.get("page", 1) - page_obj = paginator.get_page(page_number) - purchases = page_obj.object_list + limit = request.GET.get("limit", 10) + purchases = Purchase.objects.order_by("-date_purchased") + page_obj = None + if int(limit) != 0: + paginator = Paginator(Purchase.objects.order_by("-date_purchased"), limit) + page_obj = paginator.get_page(page_number) + purchases = page_obj.object_list + context = { "title": "Manage purchases", - "page_obj": page_obj, - "elided_page_range": page_obj.paginator.get_elided_page_range( - page_number, on_each_side=1, on_ends=1 + "page_obj": page_obj or None, + "elided_page_range": ( + page_obj.paginator.get_elided_page_range( + page_number, on_each_side=1, on_ends=1 + ) + if page_obj + else None ), "data": { "columns": [ diff --git a/games/static/base.css b/games/static/base.css index fef6550..94ad2d7 100644 --- a/games/static/base.css +++ b/games/static/base.css @@ -1511,6 +1511,10 @@ input:checked + .toggle-bg { max-width: 20rem; } +.max-w-screen-2xl { + max-width: 1536px; +} + .max-w-screen-lg { max-width: 1024px; } @@ -1523,18 +1527,6 @@ input:checked + .toggle-bg { max-width: 20rem; } -.max-w-screen-sm { - max-width: 640px; -} - -.max-w-screen-xl { - max-width: 1280px; -} - -.max-w-screen-2xl { - max-width: 1536px; -} - .flex-1 { flex: 1 1 0%; } @@ -1615,10 +1607,6 @@ input:checked + .toggle-bg { grid-template-columns: repeat(7, minmax(0, 1fr)); } -.flex-row { - flex-direction: row; -} - .flex-col { flex-direction: column; } @@ -1703,10 +1691,6 @@ input:checked + .toggle-bg { white-space: nowrap; } -.overflow-ellipsis { - text-overflow: ellipsis; -} - .text-ellipsis { text-overflow: ellipsis; } @@ -1857,10 +1841,6 @@ input:checked + .toggle-bg { padding: 1rem; } -.p-6 { - padding: 1.5rem; -} - .px-2 { padding-left: 0.5rem; padding-right: 0.5rem; @@ -1911,10 +1891,6 @@ input:checked + .toggle-bg { padding-bottom: 1rem; } -.pb-16 { - padding-bottom: 4rem; -} - .pl-3 { padding-left: 0.75rem; } @@ -1931,18 +1907,10 @@ input:checked + .toggle-bg { padding-top: 0.5rem; } -.pt-4 { - padding-top: 1rem; -} - .pt-8 { padding-top: 2rem; } -.pb-4 { - padding-bottom: 1rem; -} - .text-left { text-align: left; } @@ -2455,14 +2423,6 @@ textarea:disabled:is(.dark *) { } } */ -.last\:border-b:last-child { - border-bottom-width: 1px; -} - -.last\:border-b-0:last-child { - border-bottom-width: 0px; -} - .odd\:bg-white:nth-child(odd) { --tw-bg-opacity: 1; background-color: rgb(255 255 255 / var(--tw-bg-opacity)); @@ -2776,6 +2736,11 @@ textarea:disabled:is(.dark *) { color: rgb(107 114 128 / var(--tw-text-opacity)); } +.dark\:text-gray-600:is(.dark *) { + --tw-text-opacity: 1; + color: rgb(75 85 99 / var(--tw-text-opacity)); +} + .dark\:text-slate-400:is(.dark *) { --tw-text-opacity: 1; color: rgb(148 163 184 / var(--tw-text-opacity)); @@ -2796,11 +2761,6 @@ textarea:disabled:is(.dark *) { color: rgb(255 255 255 / var(--tw-text-opacity)); } -.dark\:text-gray-600:is(.dark *) { - --tw-text-opacity: 1; - color: rgb(75 85 99 / var(--tw-text-opacity)); -} - .odd\:dark\:bg-gray-900:is(.dark *):nth-child(odd) { --tw-bg-opacity: 1; background-color: rgb(17 24 39 / var(--tw-bg-opacity)); @@ -2876,6 +2836,11 @@ textarea:disabled:is(.dark *) { --tw-ring-color: rgb(63 131 248 / var(--tw-ring-opacity)); } +.dark\:focus\:ring-gray-700:focus:is(.dark *) { + --tw-ring-opacity: 1; + --tw-ring-color: rgb(55 65 81 / var(--tw-ring-opacity)); +} + .dark\:focus\:ring-green-500:focus:is(.dark *) { --tw-ring-opacity: 1; --tw-ring-color: rgb(14 159 110 / var(--tw-ring-opacity)); diff --git a/games/templates/components/simple_table.html b/games/templates/components/simple_table.html index 8dd49df..e3379cf 100644 --- a/games/templates/components/simple_table.html +++ b/games/templates/components/simple_table.html @@ -12,37 +12,39 @@ {% endfor %} - + {% if page_obj %} + + {% endif %}