1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-05-20 04:51:25 +00:00

Compare commits

..

No commits in common. "1d01376703b5cd904b8ca88ce6599b38a691bf6a" and "9380fbaaf710315c971c54b859e21b0c32177c38" have entirely different histories.

5 changed files with 40 additions and 107 deletions

View File

@ -12,9 +12,8 @@ class ParticipationConfig(AppConfig):
name = 'participation' name = 'participation'
def ready(self): def ready(self):
from participation import signals from participation.signals import create_notes, create_team_participation, update_mailing_list
pre_save.connect(signals.update_mailing_list, "participation.Team") pre_save.connect(update_mailing_list, "participation.Team")
post_save.connect(signals.create_team_participation, "participation.Team") post_save.connect(create_team_participation, "participation.Team")
post_save.connect(signals.create_payments, "participation.Participation") post_save.connect(create_notes, "participation.Passage")
post_save.connect(signals.create_notes, "participation.Passage") post_save.connect(create_notes, "participation.Pool")
post_save.connect(signals.create_notes, "participation.Pool")

View File

@ -2,8 +2,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
from typing import Union from typing import Union
from participation.models import Note, Participation, Passage, Pool, Team, Tournament from participation.models import Note, Participation, Passage, Pool, Team
from registration.models import Payment
from tfjm.lists import get_sympa_client from tfjm.lists import get_sympa_client
@ -37,41 +36,6 @@ def update_mailing_list(instance: Team, raw, **_):
f"{coach.user.first_name} {coach.user.last_name}") f"{coach.user.first_name} {coach.user.last_name}")
def create_payments(instance: Participation, created, raw, **_):
"""
When a participation got created, create an associated payment.
"""
if instance.valid and not raw:
for student in instance.team.students.all():
payment_qs = Payment.objects.filter(registrations=student, final=False)
if payment_qs.exists():
payment = payment_qs.get()
else:
payment = Payment.objects.create()
payment.registrations.add(student)
payment.save()
payment.amount = instance.tournament.price
if payment.amount == 0:
payment.type = "free"
payment.valid = True
payment.save()
if instance.final:
for student in instance.team.students.all():
payment_qs = Payment.objects.filter(registrations=student, final=True)
if payment_qs.exists():
payment = payment_qs.get()
else:
payment = Payment.objects.create(final=True)
payment.registrations.add(student)
payment.save()
payment.amount = Tournament.final_tournament().price
if payment.amount == 0:
payment.type = "free"
payment.valid = True
payment.save()
def create_notes(instance: Union[Passage, Pool], raw, **_): def create_notes(instance: Union[Passage, Pool], raw, **_):
if not raw: if not raw:
if isinstance(instance, Pool): if isinstance(instance, Pool):

View File

@ -5,42 +5,16 @@
<title>Équipe validée TFJM²</title> <title>Équipe validée TFJM²</title>
</head> </head>
<body> <body>
<p> Bonjour,<br/>
Bonjour {{ registration }}, <br/>
</p> Félicitations ! Votre équipe « {{ team.name }} » ({{ team.trigram }}) est désormais validée ! Vous êtes désormais apte
<p> à travailler sur vos problèmes. Vous pourrez ensuite envoyer vos solutions sur la plateforme.<br>
Félicitations ! Votre équipe « {{ team.name }} » ({{ team.trigram }}) est désormais validée ! Vous êtes désormais Les organisateurs vous adressent ce message :<br/>
apte à travailler sur vos problèmes. Vous pourrez ensuite envoyer vos solutions sur la plateforme. <br/>
</p> {{ message }}<br />
<br/>
{% if payment %} Cordialement,<br/>
<p> <br/>
Vous devez désormais vous acquitter de vos frais d'inscription, de {{ payment.amount }} € par élève. Le comité d'organisation du TFJM²
Vous pouvez payer par carte bancaire ou par virement bancaire. Vous trouverez les informations
sur <a href="https://{{ domain }}{% url 'registration:update_payment' pk=payment.pk %}">la page de paiement</a>.
Si vous disposez d'une bourse, l'inscription est gratuite, mais vous devez soumettre un justificatif
sur la même page.
</p>
{% elif registration.is_coach and team.participation.tournament.amount %}
<p>
Votre équipe doit désormais s'acquitter des frais d'inscription de {{ team.participation.tournament.amount }} €
par élève (les encadrant⋅es sont exonéré⋅es). Les élèves qui disposent d'une bourse sont exonéré⋅es de ces frais.
Vous pouvez suivre l'état des paiements sur
<a href="https://{{ domain }}{% url 'participation:team_detail' pk=team.pk %}">la page de votre équipe</a>.
</p>
{% endif %}
{% if message %}
<p>
Les organisateur⋅ices vous adressent ce message :
</p>
<p>
{{ message }}
</p>
{% endif %}
<p>
Le comité d'organisation du TFJM²
</p>
</body> </body>
</html> </html>

View File

@ -1,23 +1,12 @@
Bonjour {{ registration }}, Bonjour,
Félicitations ! Votre équipe « {{ team.name }} » ({{ team.trigram }}) est désormais validée ! Vous êtes désormais apte Félicitations ! Votre équipe « {{ team.name }} » ({{ team.trigram }}) est désormais validée ! Vous êtes désormais apte
à travailler sur vos problèmes. Vous pourrez ensuite envoyer vos solutions sur la plateforme. à travailler sur vos problèmes. Vous pourrez ensuite envoyer vos solutions sur la plateforme.
{% if team.participation.amount %}
Vous devez désormais vous acquitter de vos frais d'inscription, de {{ team.participation.amount }} €. Les organisateurs vous adressent ce message :
Vous pouvez payer par carte bancaire ou par virement bancaire. Vous trouverez les informations
sur la page de paiement que vous pouvez retrouver sur votre compte :
https://{{ domain }}{% url 'registration:my_account_detail' %}
Si vous disposez d'une bourse, l'inscription est gratuite, mais vous devez soumettre un justificatif
sur la même page.
{% elif registration.is_coach and team.participation.tournament.amount %}
Votre équipe doit désormais s'acquitter des frais d'inscription de {{ team.participation.tournament.amount }} €
par élève (les encadrant⋅es sont exonéré⋅es). Les élèves qui disposent d'une bourse sont exonéré⋅es de ces frais.
Vous pouvez suivre l'état des paiements sur la page de votre équipe :
https://{{ domain }}{% url 'participation:team_detail' pk=team.pk %}
{% endif %}
{% if message %}
Les organisateurices vous adressent ce message :
{{ message }} {{ message }}
{% endif %}
Cordialement,
Le comité d'organisation du TFJM² Le comité d'organisation du TFJM²

View File

@ -244,18 +244,25 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
if "validate" in self.request.POST: if "validate" in self.request.POST:
self.object.participation.valid = True self.object.participation.valid = True
self.object.participation.save() self.object.participation.save()
mail_context = dict(team=self.object, message=form.cleaned_data["message"])
domain = Site.objects.first().domain
for registration in self.object.participants.all():
if registration.is_student and self.object.participation.tournament.amount:
payment = Payment.objects.get(registrations=registration, final=False)
else:
payment = None
mail_context = dict(domain=domain, registration=registration, team=self.object, payment=payment,
message=form.cleaned_data["message"])
mail_plain = render_to_string("participation/mails/team_validated.txt", mail_context) mail_plain = render_to_string("participation/mails/team_validated.txt", mail_context)
mail_html = render_to_string("participation/mails/team_validated.html", mail_context) mail_html = render_to_string("participation/mails/team_validated.html", mail_context)
registration.user.email_user("[TFJM²] Équipe validée", mail_plain, html_message=mail_html) send_mail("[TFJM²] Équipe validée", mail_plain, None, [self.object.email], html_message=mail_html)
for student in self.object.students.all():
payment_qs = Payment.objects.filter(registrations=student)
if payment_qs.exists():
payment = payment_qs.get()
else:
payment = Payment.objects.create()
payment.registrations.add(student)
payment.save()
payment.amount = self.object.participation.tournament.price
if payment.amount == 0:
payment.type = "free"
payment.valid = True
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()