From 11135898543370ecf4ffa95dbea14cba4c33f57c Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 26 Aug 2024 10:01:01 +0200 Subject: [PATCH 1/1] View unused covers. --- src/cover/templates/cover/image_list.html | 19 +++++++++++++++---- src/cover/views.py | 7 ++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/cover/templates/cover/image_list.html b/src/cover/templates/cover/image_list.html index 02a3268d..1f69a55e 100644 --- a/src/cover/templates/cover/image_list.html +++ b/src/cover/templates/cover/image_list.html @@ -7,14 +7,25 @@ {% block content %}
-

{% trans "Cover images" %}

+

{% trans "Cover images" %}{% if only_unused %} (nieużywane){% endif %}

-{% if can_add %} - {% trans "Add new" %} -{% endif %} +
+ {% if can_add %} + {% trans "Add new" %} + {% endif %} + {% if only_unused %} + + Pokaż wszystkie + + {% else %} + + Pokaż tylko nieużywane + + {% endif %} +
{% autopaginate object_list 100 %} {% for image in object_list %} diff --git a/src/cover/views.py b/src/cover/views.py index 5ea4a6c2..302f5f52 100644 --- a/src/cover/views.py +++ b/src/cover/views.py @@ -150,9 +150,14 @@ def image_file(request, pk): @active_tab('cover') def image_list(request): + qs = Image.objects.all().order_by('-id') + only_unused = request.GET.get('unused') + if only_unused: + qs = qs.filter(book=None) return render(request, "cover/image_list.html", { - 'object_list': Image.objects.all().order_by('-id'), + 'object_list': qs, 'can_add': request.user.has_perm('cover.add_image'), + 'only_unused': only_unused, }) -- 2.20.1