From 944bb127e285dcfa3c7721bdf36d3cca2a71d4d3 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 12 Sep 2021 22:29:57 +0200 Subject: [PATCH] [WEI] New UI is working Signed-off-by: Yohann D'ANELLO --- apps/wei/templates/wei/1A_list.html | 2 +- apps/wei/templates/wei/attribute_bus_1A.html | 30 +++++++++++++++++++- apps/wei/urls.py | 3 +- apps/wei/views.py | 16 +++++++++-- 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/apps/wei/templates/wei/1A_list.html b/apps/wei/templates/wei/1A_list.html index 044db80e..d9b82937 100644 --- a/apps/wei/templates/wei/1A_list.html +++ b/apps/wei/templates/wei/1A_list.html @@ -12,7 +12,7 @@
{% render_table bus_repartition_table %}
- {% trans "Start attribution!" %} + {% trans "Start attribution!" %}
{% render_table table %}
diff --git a/apps/wei/templates/wei/attribute_bus_1A.html b/apps/wei/templates/wei/attribute_bus_1A.html index dbfb6494..32cc27dd 100644 --- a/apps/wei/templates/wei/attribute_bus_1A.html +++ b/apps/wei/templates/wei/attribute_bus_1A.html @@ -49,7 +49,7 @@
{% for bus, score in survey.ordered_buses %} - {% endfor %} @@ -58,3 +58,31 @@ {% endblock %} + +{% block extrajavascript %} + +{% endblock %} diff --git a/apps/wei/urls.py b/apps/wei/urls.py index ff6e88c5..fb497216 100644 --- a/apps/wei/urls.py +++ b/apps/wei/urls.py @@ -6,7 +6,7 @@ from django.urls import path from .views import CurrentWEIDetailView, WEI1AListView, WEIListView, WEICreateView, WEIDetailView, WEIUpdateView, \ WEIRegistrationsView, WEIMembershipsView, MemberListRenderView, \ BusCreateView, BusManageView, BusUpdateView, BusTeamCreateView, BusTeamManageView, BusTeamUpdateView, \ - WEIAttributeBus1AView, WEIRegister1AView, WEIRegister2AView, WEIUpdateRegistrationView, \ + WEIAttributeBus1AView, WEIAttributeBus1ANextView, WEIRegister1AView, WEIRegister2AView, WEIUpdateRegistrationView, \ WEIDeleteRegistrationView, WEIValidateRegistrationView, WEISurveyView, WEISurveyEndView, WEIClosedView app_name = 'wei' @@ -41,4 +41,5 @@ urlpatterns = [ path('survey//end/', WEISurveyEndView.as_view(), name="wei_survey_end"), path('detail//closed/', WEIClosedView.as_view(), name="wei_closed"), path('bus-1A//', WEIAttributeBus1AView.as_view(), name="wei_bus_1A"), + path('bus-1A/next//', WEIAttributeBus1ANextView.as_view(), name="wei_bus_1A_next"), ] diff --git a/apps/wei/views.py b/apps/wei/views.py index d0601c63..0f08e06f 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -13,7 +13,7 @@ from django.core.exceptions import PermissionDenied from django.db import transaction from django.db.models import Q, Count from django.db.models.functions.text import Lower -from django.http import HttpResponse +from django.http import HttpResponse, Http404 from django.shortcuts import redirect from django.template.loader import render_to_string from django.urls import reverse_lazy @@ -1175,7 +1175,7 @@ class WEI1AListView(LoginRequiredMixin, ProtectQuerysetMixin, SingleTableView): def get_queryset(self, filter_permissions=True, **kwargs): qs = super().get_queryset(filter_permissions, **kwargs) qs = qs.filter(first_year=True, membership__isnull=False) - qs = qs.order_by('membership__bus') + qs = qs.order_by('-membership__bus') return qs def get_context_data(self, **kwargs): @@ -1200,3 +1200,15 @@ class WEIAttributeBus1AView(ProtectQuerysetMixin, DetailView): context['club'] = self.object.wei context['survey'] = CurrentSurvey(self.object) return context + + +class WEIAttributeBus1ANextView(LoginRequiredMixin, RedirectView): + def get_redirect_url(self, *args, **kwargs): + wei = WEIClub.objects.filter(pk=self.kwargs['pk']) + if not wei.exists(): + raise Http404 + wei = wei.get() + qs = WEIRegistration.objects.filter(wei=wei, membership__isnull=False, membership__bus__isnull=True) + if qs.exists(): + return reverse_lazy('wei:wei_bus_1A', args=(qs.first().pk, )) + return reverse_lazy('wei_1A_list', args=(wei.pk, ))