posters: fix broken moderation view

This commit is contained in:
2025-10-31 12:14:33 +01:00
parent 459edc1b6e
commit b8429a510f
4 changed files with 78 additions and 64 deletions

View File

@@ -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."""

View File

@@ -12,14 +12,11 @@
<div id="poster_list" x-data="{ active: null }">
<div id="title">
<h3>{% trans %}Posters{% endtrans %}</h3>
<div id="links" class="right">
{% if app == "com" %}
<a id="create" class="link" href="{{ url(app + ":poster_create") }}">{% trans %}Create{% endtrans %}</a>
<a id="moderation" class="link" href="{{ url("com:poster_moderate_list") }}">{% trans %}Moderation{% endtrans %}</a>
{% elif app == "club" %}
<a id="create" class="link" href="{{ url(app + ":poster_create", club.id) }}">{% trans %}Create{% endtrans %}</a>
{% endif %}
<h3>{{ links["title"] }}</h3>
<div id="links" class="{{ links["position"] }}">
{% for link in links["links"] %}
<a id="{{ link["pk"] }}" class="link" href="{{ link["url"] }}">{{ link["label"] }}</a>
{% endfor %}
</div>
</div>
@@ -43,11 +40,7 @@
<div class="begin">{{ poster.date_begin | localtime | date("d/M/Y H:m") }}</div>
<div class="end">{{ poster.date_end | localtime | date("d/M/Y H:m") }}</div>
</div>
{% if app == "com" %}
<a class="edit" href="{{ url(app + ":poster_edit", poster.id) }}">{% trans %}Edit{% endtrans %}</a>
{% elif app == "club" %}
<a class="edit" href="{{ url(app + ":poster_edit", club.id, poster.id) }}">{% trans %}Edit{% endtrans %}</a>
{% endif %}
<a class="{{ action["class"] }}" href="{{ action["get_url"](club, poster) }}">{{ action["label"] }}</a>
<div class="tooltip">
<ul>
{% for screen in poster.screens.all() %}

View File

@@ -1,43 +0,0 @@
{% extends "core/base.jinja" %}
{% block script %}
{{ super() }}
<script src="{{ static('com/js/poster_list.js') }}"></script>
{% endblock %}
{% block additional_css %}
<link rel="stylesheet" href="{{ static('com/css/posters.scss') }}">
{% endblock %}
{% block content %}
<div id="poster_list">
<div id="title">
<div id="links" class="left">
<a id="list" class="link" href="{{ url("com:poster_list") }}">{% trans %}List{% endtrans %}</a>
</div>
<h3>{% trans %}Posters - moderation{% endtrans %}</h3>
</div>
<div id="posters">
{% if object_list.count == 0 %}
<div id="no-posters">{% trans %}No objects{% endtrans %}</div>
{% else %}
{% for poster in object_list %}
<div class="poster{% if not poster.is_moderated %} not_moderated{% endif %}">
<div class="name"> {{ poster.name }} </div>
<div class="image"> <img src="{{ poster.file.url }}"></img> </div>
<a class="moderate" href="{{ url("com:poster_moderate", object_id=poster.id) }}">Moderate</a>
</div>
{% endfor %}
{% endif %}
</div>
<div id="view"><div id="placeholder"></div></div>
</div>
{% endblock %}

View File

@@ -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):