1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-08-04 23:03:46 +02:00

If the tournament is free, then the payment is automatically valid

This commit is contained in:
Yohann D'ANELLO
2021-01-18 21:30:26 +01:00
parent 38dc00b2c9
commit d05a8339fe
5 changed files with 21 additions and 13 deletions

View File

@@ -173,11 +173,11 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
context["validation_form"] = ValidateParticipationForm(self.request.POST or None)
# A team is complete when there are at least 4 members plus a coache that have sent their authorizations,
# their health sheet, they confirmed their email address and under-18 people sent their parental authorization.
context["can_validate"] = team.students.count() >= 4 and team.coachs.exists() and \
all(r.email_confirmed for r in team.students.all()) and \
all(r.photo_authorization for r in team.participants.all()) and \
all(r.health_sheet for r in team.participants.all()) and \
all(r.parental_authorization for r in team.students.all() if r.under_18)
context["can_validate"] = team.students.count() >= 4 and team.coaches.exists() and \
all(r.email_confirmed for r in team.students.all()) and \
all(r.photo_authorization for r in team.participants.all()) and \
all(r.health_sheet for r in team.participants.all()) and \
all(r.parental_authorization for r in team.students.all() if r.under_18)
return context
@@ -240,8 +240,16 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
mail_html = render_to_string("participation/mails/team_validated.html", mail_context)
send_mail("[TFJM²] Équipe validée", mail_plain, None, [self.object.email], html_message=mail_html)
get_sympa_client().subscribe(self.object.email, "equipes", False, f"Equipe {self.object.name}")
get_sympa_client().unsubscribe(self.object.email, "equipes-non-valides", False)
if self.object.participation.tournament.price == 0:
for registration in self.object.participants.all():
registration.payment.type = "free"
registration.payment.valid = True
registration.payment.save()
else:
for coach in self.object.coaches.all():
coach.payment.type = "free"
coach.payment.valid = True
coach.payment.save()
elif "invalidate" in self.request.POST:
self.object.participation.valid = None
self.object.participation.save()
@@ -372,7 +380,7 @@ class TeamLeaveView(LoginRequiredMixin, TemplateView):
Matrix.kick(f"#equipe-{team.trigram.lower()}:tfjm.org",
f"@{request.user.registration.matrix_username}:tfjm.org",
"Équipe quittée")
if team.students.count() + team.coachs.count() == 0:
if team.students.count() + team.coaches.count() == 0:
team.delete()
return redirect(reverse_lazy("index"))