From 9b98c0a7f149143d636c38af3ab86dec081eec27 Mon Sep 17 00:00:00 2001 From: Felix Rindt Date: Wed, 27 Nov 2024 23:42:58 +0100 Subject: [PATCH] fix disposition permission check --- ephios/core/templatetags/event_extras.py | 2 +- tests/core/test_event_detail.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ephios/core/templatetags/event_extras.py b/ephios/core/templatetags/event_extras.py index 82d1c35da..1666e20d4 100644 --- a/ephios/core/templatetags/event_extras.py +++ b/ephios/core/templatetags/event_extras.py @@ -177,6 +177,6 @@ def event_plugin_actions(event_detail_view): @register.filter def can_do_disposition_for(user: UserProfile, shift): return ( - user.has_perm("core:change_event", shift.event) + user.has_perm("change_event", shift.event) and shift.structure.disposition_participation_form_class is not None ) diff --git a/tests/core/test_event_detail.py b/tests/core/test_event_detail.py index 12bc7549d..3ab29f316 100644 --- a/tests/core/test_event_detail.py +++ b/tests/core/test_event_detail.py @@ -21,3 +21,20 @@ def test_event_slug_with_empty_name(django_app, volunteer, event): assert response.location # is a redirect response = response.follow() assert event.description in response + + +def test_show_disposition_button(django_app, volunteer, planner, event): + assert ( + "Disposition" + not in django_app.get( + reverse("core:event_detail", kwargs=dict(pk=event.pk, slug="nottheactualslug")), + user=volunteer, + ).follow() + ) + assert ( + "Disposition" + in django_app.get( + reverse("core:event_detail", kwargs=dict(pk=event.pk, slug="nottheactualslug")), + user=planner, + ).follow() + )