From 5ad0cb74cc469037e8eca035c2639ccc6d14ffbd Mon Sep 17 00:00:00 2001 From: moanos <julian-samuel@gebuehr.net> Date: Sun, 9 Mar 2025 18:05:03 +0100 Subject: [PATCH] feat: Only show edit buttons when mod --- .../partials/partial-report.html | 26 ++++++++++--------- src/fellchensammlung/views.py | 4 ++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/fellchensammlung/templates/fellchensammlung/partials/partial-report.html b/src/fellchensammlung/templates/fellchensammlung/partials/partial-report.html index d07606c..eabaf7c 100644 --- a/src/fellchensammlung/templates/fellchensammlung/partials/partial-report.html +++ b/src/fellchensammlung/templates/fellchensammlung/partials/partial-report.html @@ -16,16 +16,18 @@ <p><b>{% translate "Kommentar zur Meldung" %}:</b> {{ report.user_comment }} </p> - <div class="container-edit-buttons"> - <form action="allow" class=""> - {% csrf_token %} - <input type="hidden" name="report_id" value="{{ report.pk }}"> - <button class="btn allow" type="submit">{% translate "Inhalt genehmigen" %}</button> - </form> - <form action="disallow" class=""> - {% csrf_token %} - <input type="hidden" name="report_id" value="{{ report.pk }}"> - <button class="btn allow" type="submit">{% translate "Inhalt als gesperrt kennzeichnen" %}</button> - </form> - </div> + {% if is_mod_or_above %} + <div class="container-edit-buttons"> + <form action="allow" class=""> + {% csrf_token %} + <input type="hidden" name="report_id" value="{{ report.pk }}"> + <button class="btn allow" type="submit">{% translate "Inhalt genehmigen" %}</button> + </form> + <form action="disallow" class=""> + {% csrf_token %} + <input type="hidden" name="report_id" value="{{ report.pk }}"> + <button class="btn allow" type="submit">{% translate "Inhalt als gesperrt kennzeichnen" %}</button> + </form> + </div> + {% endif %} </div> \ No newline at end of file diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index 8e431f6..cd7b87d 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -431,8 +431,10 @@ def report_detail(request, report_id, form_complete=False): """ report = Report.objects.get(pk=report_id) moderation_actions = ModerationAction.objects.filter(report_id=report_id) + is_mod_or_above = user_is_trust_level_or_above(request.user, TrustLevel.MODERATOR) - context = {"report": report, "moderation_actions": moderation_actions, "form_complete": form_complete} + context = {"report": report, "moderation_actions": moderation_actions, + "form_complete": form_complete, "is_mod_or_above": is_mod_or_above} return render(request, 'fellchensammlung/details/detail-report.html', context)