From f641019a93f719aae25a9c32b57536a102d2fbbc Mon Sep 17 00:00:00 2001 From: Dominik Weitz <dominik.weitz@ovgu.de> Date: Fri, 6 Nov 2020 20:47:18 +0100 Subject: [PATCH] Add "Express Interest" button to AK overview --- AKSubmission/templates/AKSubmission/ak_table.html | 3 +++ AKSubmission/urls.py | 1 + AKSubmission/views.py | 14 ++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/AKSubmission/templates/AKSubmission/ak_table.html b/AKSubmission/templates/AKSubmission/ak_table.html index 732b96cb..5872c74b 100644 --- a/AKSubmission/templates/AKSubmission/ak_table.html +++ b/AKSubmission/templates/AKSubmission/ak_table.html @@ -52,6 +52,9 @@ <a href="{% url 'submit:ak_edit' event_slug=event.slug pk=ak.pk %}" data-toggle="tooltip" title="{% trans 'Edit' %}" class="btn btn-success">{% fa5_icon 'pencil-alt' 'fas' %}</a> + <a href="{% url 'submit:overview_inc_interest' event_slug=event.slug pk=ak.pk %}" data-toggle="tooltip" + title="{% trans 'Show Interest' %}" + class="btn btn-primary">{% fa5_icon 'thumbs-up' 'fas' %}</a> {% endif %} </td> </tr> diff --git a/AKSubmission/urls.py b/AKSubmission/urls.py index 0e08c5b0..e22ffdfd 100644 --- a/AKSubmission/urls.py +++ b/AKSubmission/urls.py @@ -13,6 +13,7 @@ urlpatterns = [ path('ak/<int:pk>/history/', views.AKHistoryView.as_view(), name='ak_history'), path('ak/<int:pk>/edit/', views.AKEditView.as_view(), name='ak_edit'), path('ak/<int:pk>/interest/', views.AKInterestView.as_view(), name='inc_interest'), + path('ak/<int:pk>/overview_interest/', views.AKOverviewInterestView.as_view(), name='overview_inc_interest'), path('ak/<int:pk>/add_slot/', views.AKSlotAddView.as_view(), name='akslot_add'), path('ak/<int:pk>/add_message/', views.AKAddOrgaMessageView.as_view(), name='akmessage_add'), path('akslot/<int:pk>/edit/', views.AKSlotEditView.as_view(), name='akslot_edit'), diff --git a/AKSubmission/views.py b/AKSubmission/views.py index e1c632aa..f83bf3de 100644 --- a/AKSubmission/views.py +++ b/AKSubmission/views.py @@ -289,6 +289,20 @@ class AKInterestView(RedirectView): return super().get_redirect_url(*args, **kwargs) +# when the interest increase request comes from the AK overview page, redirect to that instead of the AK overview page +class AKOverviewInterestView(RedirectView): + permanent = False + pattern_name = 'submit:submission_overview' + + def get_redirect_url(self, *args, **kwargs): + ak = get_object_or_404(AK, pk=kwargs['pk']) + if ak.event.active: + ak.increment_interest() + messages.add_message(self.request, messages.SUCCESS, _("Interest saved")) + del kwargs['pk'] + return super().get_redirect_url(*args, **kwargs) + + class AKOwnerCreateView(EventSlugMixin, EventInactiveRedirectMixin, CreateView): model = AKOwner template_name = 'AKSubmission/akowner_create_update.html' -- GitLab