mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-29 20:51:11 +02:00
Année et algorithme
This commit is contained in:
@ -1422,3 +1422,29 @@ class WEIAttributeBus1ANextView(LoginRequiredMixin, RedirectView):
|
||||
|
||||
# On redirige vers la page d'attribution pour le premier étudiant trouvé
|
||||
return reverse_lazy('wei:wei_bus_1A', args=(qs.first().pk,))
|
||||
|
||||
|
||||
class BusInformationUpdateView(ProtectQuerysetMixin, LoginRequiredMixin, UpdateView):
|
||||
model = Bus
|
||||
|
||||
def get_form_class(self):
|
||||
return CurrentSurvey.get_algorithm_class().get_bus_information_form()
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
wei = self.get_object().wei
|
||||
today = date.today()
|
||||
# We can't update a bus once the WEI is started
|
||||
if today >= wei.date_start:
|
||||
return redirect(reverse_lazy('wei:wei_closed', args=(wei.pk,)))
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["club"] = self.object.wei
|
||||
context["information"] = CurrentSurvey.get_algorithm_class().get_bus_information(self.object)
|
||||
self.object.save()
|
||||
return context
|
||||
|
||||
def get_success_url(self):
|
||||
self.object.refresh_from_db()
|
||||
return reverse_lazy("wei:manage_bus", kwargs={"pk": self.object.pk})
|
Reference in New Issue
Block a user