Students can't auto-select them for the final

This commit is contained in:
Emmy D'Anello 2023-01-22 15:49:42 +01:00
parent b95b41a2ed
commit 0e7be7e27c
1 changed files with 4 additions and 0 deletions

View File

@ -305,12 +305,16 @@ class TeamUpdateView(LoginRequiredMixin, UpdateView):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context["participation_form"] = ParticipationForm(data=self.request.POST or None, context["participation_form"] = ParticipationForm(data=self.request.POST or None,
instance=self.object.participation) instance=self.object.participation)
if not self.request.user.registration.is_volunteer:
del context["participation_form"].fields['final']
context["title"] = _("Update team {trigram}").format(trigram=self.object.trigram) context["title"] = _("Update team {trigram}").format(trigram=self.object.trigram)
return context return context
@transaction.atomic @transaction.atomic
def form_valid(self, form): def form_valid(self, form):
participation_form = ParticipationForm(data=self.request.POST or None, instance=self.object.participation) participation_form = ParticipationForm(data=self.request.POST or None, instance=self.object.participation)
if not self.request.user.registration.is_volunteer:
del participation_form.fields['final']
if not participation_form.is_valid(): if not participation_form.is_valid():
return self.form_invalid(form) return self.form_invalid(form)