diff --git a/games/purchaseviews.py b/games/purchaseviews.py index c740786..0f68a5b 100644 --- a/games/purchaseviews.py +++ b/games/purchaseviews.py @@ -1,6 +1,7 @@ from typing import Any from django.contrib.auth.decorators import login_required +from django.core.paginator import Paginator from django.db.models.manager import BaseManager from django.http import HttpRequest, HttpResponse from django.shortcuts import render @@ -14,9 +15,16 @@ from games.views import dateformat @login_required def list_purchases(request: HttpRequest) -> HttpResponse: context: dict[Any, Any] = {} - purchases: BaseManager[Purchase] = Purchase.objects.all()[0:10] + paginator = Paginator(Purchase.objects.order_by("created_at"), 10) + page_number = request.GET.get("page", 1) + 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 + ), "data": { "columns": [ "Name", diff --git a/games/static/base.css b/games/static/base.css index c4faa99..75bea80 100644 --- a/games/static/base.css +++ b/games/static/base.css @@ -1370,6 +1370,10 @@ input:checked + .toggle-bg { margin-bottom: 0.75rem; } +.mb-4 { + margin-bottom: 1rem; +} + .mb-8 { margin-bottom: 2rem; } @@ -1382,6 +1386,10 @@ input:checked + .toggle-bg { margin-right: 1rem; } +.ms-0 { + margin-inline-start: 0px; +} + .mt-2 { margin-top: 0.5rem; } @@ -1451,6 +1459,10 @@ input:checked + .toggle-bg { height: 1.5rem; } +.h-8 { + height: 2rem; +} + .h-9 { height: 2.25rem; } @@ -1639,6 +1651,12 @@ input:checked + .toggle-bg { gap: 1.25rem; } +.-space-x-px > :not([hidden]) ~ :not([hidden]) { + --tw-space-x-reverse: 0; + margin-right: calc(-1px * var(--tw-space-x-reverse)); + margin-left: calc(-1px * calc(1 - var(--tw-space-x-reverse))); +} + .space-x-1 > :not([hidden]) ~ :not([hidden]) { --tw-space-x-reverse: 0; margin-right: calc(0.25rem * var(--tw-space-x-reverse)); @@ -1885,6 +1903,10 @@ input:checked + .toggle-bg { padding-top: 0.5rem; } +.pt-4 { + padding-top: 1rem; +} + .pt-8 { padding-top: 2rem; } @@ -1966,6 +1988,10 @@ input:checked + .toggle-bg { font-weight: 500; } +.font-normal { + font-weight: 400; +} + .font-semibold { font-weight: 600; } @@ -1982,6 +2008,10 @@ input:checked + .toggle-bg { line-height: 2.25rem; } +.leading-tight { + line-height: 1.25; +} + .text-blue-600 { --tw-text-opacity: 1; color: rgb(28 100 242 / var(--tw-text-opacity)); @@ -2474,6 +2504,11 @@ textarea:disabled:is(.dark *) { color: rgb(75 85 99 / var(--tw-text-opacity)); } +.hover\:text-gray-700:hover { + --tw-text-opacity: 1; + color: rgb(55 65 81 / var(--tw-text-opacity)); +} + .hover\:text-gray-900:hover { --tw-text-opacity: 1; color: rgb(17 24 39 / var(--tw-text-opacity)); @@ -2845,10 +2880,18 @@ textarea:disabled:is(.dark *) { } @media (min-width: 768px) { + .md\:mb-0 { + margin-bottom: 0px; + } + .md\:block { display: block; } + .md\:inline { + display: inline; + } + .md\:w-auto { width: auto; } @@ -2904,31 +2947,3 @@ textarea:disabled:is(.dark *) { border-start-end-radius: 0.5rem; border-end-end-radius: 0.5rem; } - -.\[\&_td\:first-of-type\]\:whitespace-nowrap td:first-of-type { - white-space: nowrap; -} - -.\[\&_td\:first-of-type\]\:px-6 td:first-of-type { - padding-left: 1.5rem; - padding-right: 1.5rem; -} - -.\[\&_td\:first-of-type\]\:py-4 td:first-of-type { - padding-top: 1rem; - padding-bottom: 1rem; -} - -.\[\&_td\:first-of-type\]\:font-medium td:first-of-type { - font-weight: 500; -} - -.\[\&_td\:first-of-type\]\:text-gray-900 td:first-of-type { - --tw-text-opacity: 1; - color: rgb(17 24 39 / var(--tw-text-opacity)); -} - -.\[\&_td\:first-of-type\]\:dark\:text-white:is(.dark *) td:first-of-type { - --tw-text-opacity: 1; - color: rgb(255 255 255 / var(--tw-text-opacity)); -} diff --git a/games/templates/components/simple_table.html b/games/templates/components/simple_table.html index a13a93a..c412e79 100644 --- a/games/templates/components/simple_table.html +++ b/games/templates/components/simple_table.html @@ -1,4 +1,5 @@ -
+
@@ -11,4 +12,37 @@ {% endfor %}
+
diff --git a/games/templates/list_purchases.html b/games/templates/list_purchases.html index 8e3b2c5..67cdc3c 100644 --- a/games/templates/list_purchases.html +++ b/games/templates/list_purchases.html @@ -4,5 +4,5 @@ {{ title }} {% endblock title %} {% block content %} - {% simple_table columns=data.columns rows=data.rows %} + {% simple_table columns=data.columns rows=data.rows page_obj=page_obj elided_page_range=elided_page_range %} {% endblock content %}