If the tournament is free, then the payment is automatically valid
This commit is contained in:
parent
38dc00b2c9
commit
d05a8339fe
|
@ -49,7 +49,7 @@ class Team(models.Model):
|
||||||
return self.participants.filter(studentregistration__isnull=False)
|
return self.participants.filter(studentregistration__isnull=False)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def coachs(self):
|
def coaches(self):
|
||||||
return self.participants.filter(coachregistration__isnull=False)
|
return self.participants.filter(coachregistration__isnull=False)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -31,7 +31,7 @@ def update_mailing_list(instance: Team, **_):
|
||||||
for student in instance.students.all():
|
for student in instance.students.all():
|
||||||
get_sympa_client().subscribe(student.user.email, f"equipe-{instance.trigram.lower()}", False,
|
get_sympa_client().subscribe(student.user.email, f"equipe-{instance.trigram.lower()}", False,
|
||||||
f"{student.user.first_name} {student.user.last_name}")
|
f"{student.user.first_name} {student.user.last_name}")
|
||||||
for coach in instance.coachs.all():
|
for coach in instance.coaches.all():
|
||||||
get_sympa_client().subscribe(coach.user.email, f"equipe-{instance.trigram.lower()}", False,
|
get_sympa_client().subscribe(coach.user.email, f"equipe-{instance.trigram.lower()}", False,
|
||||||
f"{coach.user.first_name} {coach.user.last_name}")
|
f"{coach.user.first_name} {coach.user.last_name}")
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,9 @@
|
||||||
<dt class="col-sm-6 text-right">{% trans "Access code:" %}</dt>
|
<dt class="col-sm-6 text-right">{% trans "Access code:" %}</dt>
|
||||||
<dd class="col-sm-6">{{ team.access_code }}</dd>
|
<dd class="col-sm-6">{{ team.access_code }}</dd>
|
||||||
|
|
||||||
<dt class="col-sm-6 text-right">{% trans "Coachs:" %}</dt>
|
<dt class="col-sm-6 text-right">{% trans "Coaches:" %}</dt>
|
||||||
<dd class="col-sm-6">
|
<dd class="col-sm-6">
|
||||||
{% for coach in team.coachs.all %}
|
{% for coach in team.coaches.all %}
|
||||||
<a href="{% url "registration:user_detail" pk=coach.user.pk %}">{{ coach }}</a>{% if not forloop.last %},{% endif %}
|
<a href="{% url "registration:user_detail" pk=coach.user.pk %}">{{ coach }}</a>{% if not forloop.last %},{% endif %}
|
||||||
{% empty %}
|
{% empty %}
|
||||||
{% trans "any" %}
|
{% trans "any" %}
|
||||||
|
|
|
@ -173,11 +173,11 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
|
||||||
context["validation_form"] = ValidateParticipationForm(self.request.POST or None)
|
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,
|
# 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.
|
# 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 \
|
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.email_confirmed for r in team.students.all()) and \
|
||||||
all(r.photo_authorization for r in team.participants.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.health_sheet for r in team.participants.all()) and \
|
||||||
all(r.parental_authorization for r in team.students.all() if r.under_18)
|
all(r.parental_authorization for r in team.students.all() if r.under_18)
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
@ -240,8 +240,16 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
|
||||||
mail_html = render_to_string("participation/mails/team_validated.html", mail_context)
|
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)
|
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}")
|
if self.object.participation.tournament.price == 0:
|
||||||
get_sympa_client().unsubscribe(self.object.email, "equipes-non-valides", False)
|
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:
|
elif "invalidate" in self.request.POST:
|
||||||
self.object.participation.valid = None
|
self.object.participation.valid = None
|
||||||
self.object.participation.save()
|
self.object.participation.save()
|
||||||
|
@ -372,7 +380,7 @@ class TeamLeaveView(LoginRequiredMixin, TemplateView):
|
||||||
Matrix.kick(f"#equipe-{team.trigram.lower()}:tfjm.org",
|
Matrix.kick(f"#equipe-{team.trigram.lower()}:tfjm.org",
|
||||||
f"@{request.user.registration.matrix_username}:tfjm.org",
|
f"@{request.user.registration.matrix_username}:tfjm.org",
|
||||||
"Équipe quittée")
|
"Équipe quittée")
|
||||||
if team.students.count() + team.coachs.count() == 0:
|
if team.students.count() + team.coaches.count() == 0:
|
||||||
team.delete()
|
team.delete()
|
||||||
return redirect(reverse_lazy("index"))
|
return redirect(reverse_lazy("index"))
|
||||||
|
|
||||||
|
|
|
@ -697,7 +697,7 @@ msgid "Access code:"
|
||||||
msgstr "Code d'accès :"
|
msgstr "Code d'accès :"
|
||||||
|
|
||||||
#: apps/participation/templates/participation/team_detail.html:25
|
#: apps/participation/templates/participation/team_detail.html:25
|
||||||
msgid "Coachs:"
|
msgid "Coaches:"
|
||||||
msgstr "Encadrants :"
|
msgstr "Encadrants :"
|
||||||
|
|
||||||
#: apps/participation/templates/participation/team_detail.html:34
|
#: apps/participation/templates/participation/team_detail.html:34
|
||||||
|
|
Loading…
Reference in New Issue