Skip to content

Commit

Permalink
fix event change permission check
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrindt committed Dec 12, 2024
1 parent 6a86a2b commit 5acc746
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 1 addition & 4 deletions ephios/core/templates/core/event_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
{% endblock %}

{% block content %}
{% if request.user.is_authenticated %}
{% get_obj_perms request.user for event as "event_perms" %}
{% endif %}
{% if not event.active %}
{% if event.shifts.exists %}
{% translate "This event has not been saved! If you are done editing the event, you can save it." as not_active_error %}
Expand All @@ -40,7 +37,7 @@
<div class="card mb-3">
<div class="card-body pb-0">
<h1 class="card-title fw-bold fs-1">
{% if "change_event" in event_perms %}
{% if can_change_event %}
<div class="dropstart float-end">
<button class="btn" type="button" id="actionDropdownButton"
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Expand Down
6 changes: 6 additions & 0 deletions ephios/core/views/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,12 @@ def get_queryset(self):
base = Event.all_objects.all()
return base.prefetch_related("shifts", "shifts__participations")

def get_context_data(self, **kwargs):
kwargs["can_change_event"] = self.object in get_objects_for_user(
self.request.user, "core.change_event"
)
return super().get_context_data(**kwargs)


class EventUpdateView(CustomPermissionRequiredMixin, PluginFormMixin, UpdateView):
model = Event
Expand Down

0 comments on commit 5acc746

Please sign in to comment.