Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change event_action_signal interface #881

Merged
merged 2 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ephios/core/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@
will contain a list of event ids on which the action should be performed.
"""

register_event_action = PluginSignal()
event_action = PluginSignal()
"""
This signal is sent out to get a list of actions that a user can perform on a single event. The actions are
displayed in the dropdown menu on the event detail view. Each action is represented by a dict with the keys
``url``, ``label`` and ``icon``. The given url will be called with a ``pk`` parameter containing the id of the event.
displayed in the dropdown menu on the event detail view.
Receivers receive a ``event`` and ``request`` keyword argument.
Each action is represented by a dict with the keys ``url``, ``label`` and ``icon``.
"""

homepage_info = PluginSignal()
Expand Down
2 changes: 1 addition & 1 deletion ephios/core/templates/core/event_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h1 class="card-title fw-bold fs-1">
{% trans "View edit history" %}
</a></li>
{% endif %}
{% event_plugin_actions event %}
{% event_plugin_actions view %}
</ul>
</div>
{% endif %}
Expand Down
11 changes: 6 additions & 5 deletions ephios/core/templatetags/event_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
from functools import reduce

from django import template
from django.urls import reverse
from django.utils import timezone
from django.utils.html import format_html
from django.utils.safestring import mark_safe

from ephios.core.models import AbstractParticipation, EventType, UserProfile
from ephios.core.signals import (
event_action,
event_info,
homepage_info,
register_event_action,
register_event_bulk_action,
shift_info,
)
Expand Down Expand Up @@ -163,12 +162,14 @@ def homepage_plugin_content(request):


@register.simple_tag(name="event_plugin_actions")
def event_plugin_actions(event):
def event_plugin_actions(event_detail_view):
html = ""
for _, actions in register_event_action.send(None):
for _, actions in event_action.send(
None, event=event_detail_view.object, request=event_detail_view.request
):
html += "".join(
[
f"<li><a class='dropdown-item' href='{reverse(action['url'], kwargs={'pk': event.id})}'><span class='fas {action['icon']}'></span> {action['label']}</a></li>"
f"<li><a class='dropdown-item' href='{action['url']}'><span class='fas {action['icon']}'></span> {action['label']}</a></li>"
for action in actions
]
)
Expand Down