mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-12-03 13:46:58 +00:00
[WEI] Avoid errors if the survey is not ended
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
parent
600ba15faa
commit
ef118c2445
@ -190,13 +190,12 @@ class WEIRegistration1ATable(tables.Table):
|
||||
attrs = {
|
||||
'class': 'table table-condensed table-striped table-hover'
|
||||
}
|
||||
model = WEIMembership
|
||||
model = WEIRegistration
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
fields = ('user', 'user__last_name', 'user__first_name', 'gender',
|
||||
'user__profile__department', 'preferred_bus', 'membership__bus', )
|
||||
row_attrs = {
|
||||
'class': 'table-row',
|
||||
'id': lambda record: "row-" + str(record.pk),
|
||||
'class': lambda record: '' if 'selected_bus_pk' in record.information else 'bg-danger',
|
||||
}
|
||||
|
||||
|
||||
|
@ -1195,6 +1195,12 @@ class WEIAttributeBus1AView(ProtectQuerysetMixin, DetailView):
|
||||
qs = qs.filter(first_year=True)
|
||||
return qs
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
obj = self.get_object()
|
||||
if 'selected_bus_pk' not in obj.information:
|
||||
return redirect(reverse_lazy('wei:wei_survey', args=(obj.pk,)))
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['club'] = self.object.wei
|
||||
@ -1209,6 +1215,7 @@ class WEIAttributeBus1ANextView(LoginRequiredMixin, RedirectView):
|
||||
raise Http404
|
||||
wei = wei.get()
|
||||
qs = WEIRegistration.objects.filter(wei=wei, membership__isnull=False, membership__bus__isnull=True)
|
||||
qs = qs.filter(information_json__contains='selected_bus_pk') # not perfect, but works...
|
||||
if qs.exists():
|
||||
return reverse_lazy('wei:wei_bus_1A', args=(qs.first().pk, ))
|
||||
return reverse_lazy('wei_1A_list', args=(wei.pk, ))
|
||||
|
Loading…
Reference in New Issue
Block a user