From b8429a510fdca312394decf44e551075f30b6a9a Mon Sep 17 00:00:00 2001 From: Sli Date: Fri, 31 Oct 2025 12:14:33 +0100 Subject: [PATCH] posters: fix broken moderation view --- club/views.py | 27 ++++++++++++- com/templates/com/poster_list.jinja | 19 +++------ com/templates/com/poster_moderate.jinja | 43 -------------------- com/views.py | 53 +++++++++++++++++++++---- 4 files changed, 78 insertions(+), 64 deletions(-) delete mode 100644 com/templates/com/poster_moderate.jinja diff --git a/club/views.py b/club/views.py index a14b71cd..ff09a5f5 100644 --- a/club/views.py +++ b/club/views.py @@ -762,7 +762,19 @@ class PosterListView(ClubTabsMixin, PosterListBaseView): """List communication posters.""" current_tab = "posters" - extra_context = {"app": "club"} + extra_context = { + "links": { + "title": _("Posters"), + "position": "right", + }, + "action": { + "class": "edit", + "label": _("Edit"), + "get_url": lambda club, poster: reverse( + "club:poster_edit", kwargs={"club_id": club.id, "poster_id": poster.id} + ), + }, + } def get_queryset(self): return super().get_queryset().filter(club=self.club.id) @@ -770,6 +782,19 @@ class PosterListView(ClubTabsMixin, PosterListBaseView): def get_object(self): return self.club + def get_context_data(self, **kwargs): + kwargs = super().get_context_data(**kwargs) + kwargs["links"]["links"] = [ + { + "pk": "create", + "label": _("Create"), + "url": reverse_lazy( + "club:poster_create", kwargs={"club_id": self.club.id} + ), + } + ] + return kwargs + class PosterCreateView(ClubTabsMixin, PosterCreateBaseView): """Create communication poster.""" diff --git a/com/templates/com/poster_list.jinja b/com/templates/com/poster_list.jinja index d723c248..fe247af5 100644 --- a/com/templates/com/poster_list.jinja +++ b/com/templates/com/poster_list.jinja @@ -12,14 +12,11 @@
-

{% trans %}Posters{% endtrans %}

- @@ -43,11 +40,7 @@
{{ poster.date_begin | localtime | date("d/M/Y H:m") }}
{{ poster.date_end | localtime | date("d/M/Y H:m") }}
- {% if app == "com" %} - {% trans %}Edit{% endtrans %} - {% elif app == "club" %} - {% trans %}Edit{% endtrans %} - {% endif %} + {{ action["label"] }}
    {% for screen in poster.screens.all() %} diff --git a/com/templates/com/poster_moderate.jinja b/com/templates/com/poster_moderate.jinja deleted file mode 100644 index 6370becf..00000000 --- a/com/templates/com/poster_moderate.jinja +++ /dev/null @@ -1,43 +0,0 @@ -{% extends "core/base.jinja" %} - -{% block script %} - {{ super() }} - -{% endblock %} - -{% block additional_css %} - -{% endblock %} - -{% block content %} -
    - -
    - -

    {% trans %}Posters - moderation{% endtrans %}

    -
    - -
    - - {% if object_list.count == 0 %} -
    {% trans %}No objects{% endtrans %}
    - {% else %} - - {% for poster in object_list %} -
    -
    {{ poster.name }}
    -
    - Moderate -
    - {% endfor %} - - {% endif %} - -
    - -
    - -
    -{% endblock %} diff --git a/com/views.py b/com/views.py index a1897b12..ee37d5cb 100644 --- a/com/views.py +++ b/com/views.py @@ -637,6 +637,31 @@ class PosterListView(ComTabsMixin, PosterListBaseView): """List communication posters.""" current_tab = "posters" + extra_context = { + "links": { + "title": _("Posters"), + "position": "right", + "links": [ + { + "pk": "create", + "label": _("Create"), + "url": reverse_lazy("com:poster_create"), + }, + { + "pk": "moderation", + "label": "Moderation", + "url": reverse_lazy("com:poster_moderate_list"), + }, + ], + }, + "action": { + "class": "edit", + "label": _("Edit"), + "get_url": lambda club, poster: reverse( + "com:poster_edit", kwargs={"poster_id": poster.id} + ), + }, + } def get_queryset(self): qs = super().get_queryset() @@ -644,11 +669,6 @@ class PosterListView(ComTabsMixin, PosterListBaseView): return qs return qs.filter(club=self.club.id) - def get_context_data(self, **kwargs): - kwargs = super().get_context_data(**kwargs) - kwargs["app"] = "com" - return kwargs - class PosterCreateView(ComTabsMixin, PosterCreateBaseView): """Create communication poster.""" @@ -677,10 +697,29 @@ class PosterModerateListView(PermissionRequiredMixin, ComTabsMixin, ListView): current_tab = "posters" model = Poster - template_name = "com/poster_moderate.jinja" + template_name = "com/poster_list.jinja" queryset = Poster.objects.filter(is_moderated=False).all() permission_required = "com.moderate_poster" - extra_context = {"app": "com"} + extra_context = { + "links": { + "position": "left", + "title": _("Posters - moderation"), + "links": [ + { + "pk": "list", + "label": _("List"), + "url": reverse_lazy("com:poster_list"), + } + ], + }, + "action": { + "class": "moderate", + "label": _("Moderate"), + "get_url": lambda club, poster: reverse( + "com:poster_moderate", kwargs={"object_id": poster.id} + ), + }, + } class PosterModerateView(PermissionRequiredMixin, ComTabsMixin, View):