From 6242e316ae8e424404a3901b153ba5670f7b17ea Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 12 Apr 2020 04:39:57 +0200 Subject: [PATCH] Update pre-registrations --- apps/wei/tables.py | 2 +- apps/wei/urls.py | 3 ++- apps/wei/views.py | 18 ++++++++++++++++++ templates/wei/weiclub_tables.html | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/apps/wei/tables.py b/apps/wei/tables.py index 0efbee34..f0541cd0 100644 --- a/apps/wei/tables.py +++ b/apps/wei/tables.py @@ -37,7 +37,7 @@ class WEIRegistrationTable(tables.Table): ) edit = tables.LinkColumn( - 'wei:wei_detail', + 'wei:wei_update_registration', args=[A('pk')], verbose_name=_("Edit"), text=_("Edit"), diff --git a/apps/wei/urls.py b/apps/wei/urls.py index de10d1f4..3d3be0f0 100644 --- a/apps/wei/urls.py +++ b/apps/wei/urls.py @@ -3,7 +3,7 @@ from django.urls import path -from .views import WEIListView, WEICreateView, WEIDetailView, WEIUpdateView, WEIRegisterView +from .views import WEIListView, WEICreateView, WEIDetailView, WEIUpdateView, WEIRegisterView, WEIUpdateRegistrationView app_name = 'wei' @@ -13,4 +13,5 @@ urlpatterns = [ path('detail//', WEIDetailView.as_view(), name="wei_detail"), path('update//', WEIUpdateView.as_view(), name="wei_update"), path('register//', WEIRegisterView.as_view(), name="wei_register"), + path('edit_registration//', WEIUpdateRegistrationView.as_view(), name="wei_update_registration"), ] diff --git a/apps/wei/views.py b/apps/wei/views.py index c5799902..60f0a164 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -136,3 +136,21 @@ class WEIRegisterView(ProtectQuerysetMixin, LoginRequiredMixin, CreateView): def get_success_url(self): self.object.refresh_from_db() return reverse_lazy("wei:wei_detail", kwargs={"pk": self.object.wei.pk}) + + +class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView): + """ + Update a registration for the WEI + """ + model = WEIRegistration + form_class = WEIRegistrationForm + + def get_form(self, form_class=None): + form = super().get_form(form_class) + del form.fields["user"] + return form + + def get_success_url(self): + self.object.refresh_from_db() + return reverse_lazy("wei:wei_detail", kwargs={"pk": self.object.wei.pk}) + diff --git a/templates/wei/weiclub_tables.html b/templates/wei/weiclub_tables.html index 6fc72e81..b1e54c7c 100644 --- a/templates/wei/weiclub_tables.html +++ b/templates/wei/weiclub_tables.html @@ -102,7 +102,7 @@
{% endif %} -{% if all_registrations.data or True %} +{% if all_registrations.data %}