add a mail notification to the umpire when team unregister and display canceled status for a team status in priority

sync_v2
Raz 6 months ago
parent 525681d7ae
commit ffdb5ce74c
  1. 10
      tournaments/models/player_registration.py
  2. 9
      tournaments/models/team_registration.py
  3. 7
      tournaments/models/tournament.py
  4. 43
      tournaments/services/email_service.py
  5. 5
      tournaments/services/tournament_unregistration.py
  6. 44
      tournaments/templates/tournaments/tournament_info.html

@ -111,6 +111,16 @@ class PlayerRegistration(SideStoreModel):
tournament = self.team_registration.tournament
tournament_status_team_count = tournament.get_tournament_status_team_count()
if tournament.is_canceled():
return {
'header': "Équipes",
'position': tournament_status_team_count,
'display_box': True,
'box_class': 'light-red',
'short_label': 'annulé'
}
status = {
'header': "Équipes",
'position': tournament_status_team_count,

@ -500,3 +500,12 @@ class TeamRegistration(SideStoreModel):
tournament,
TeamEmailType.REQUIRES_TIME_CONFIRMATION
)
def is_unregistration_possible(self):
if self.call_date is not None:
return False
if self.bracket_position is not None:
return False
if self.group_stage_position is not None:
return False
return True

@ -974,8 +974,8 @@ class Tournament(BaseModel):
timezoned_datetime -= timedelta(hours=hour_delta)
return now >= timezoned_datetime
def will_start_soon(self):
return self.has_started(hour_delta=2)
def will_start_soon(self, hour_delta=2):
return self.has_started(hour_delta=hour_delta)
def supposedly_in_progress(self):
# end = self.start_date + timedelta(days=self.day_duration + 1)
@ -1214,6 +1214,9 @@ class Tournament(BaseModel):
if self.supposedly_in_progress():
return False
if self.will_start_soon(12):
return False
if self.closed_registration_date is not None:
return False

@ -606,6 +606,49 @@ class TournamentEmailService:
# If there's only one player, just send them the notification
TournamentEmailService.notify(players[0], None, tournament, message_type)
@staticmethod
def notify_umpire(team, tournament, message_type):
# Notify the umpire if needed
umpire_email = tournament.umpire_mail()
if umpire_email:
tournament_details_str = tournament.build_tournament_details_str()
federal_level_category = FederalLevelCategory(tournament.federal_level_category)
tournament_word = federal_level_category.localized_word()
tournament_prefix_that = federal_level_category.localized_prefix_that()
body_parts = [
"Email automatique suite à une désinscription",
f"\n\n{tournament_details_str} | {tournament.formatted_start_date()} | {tournament.event.club.name}"
"\n\nL'équipe ci-dessous a annulé son inscription via le site PadelClub :",
]
for player in team.players_sorted_by_rank:
body_parts.append(
f"\n{player.name()}"
)
absolute_url = f"https://padelclub.app/tournament/{tournament.id}/info"
link_text = f"informations sur {tournament_prefix_that}{tournament_word} sur https://padelclub.app"
absolute_url = f'<a href="{absolute_url}">{link_text}</a>'
body_parts.append(
f"\n\nVoir les {absolute_url}",
)
body_parts.extend([
"\n\nCeci est un e-mail automatique."
])
email_body = "".join(body_parts)
if email_body is None:
return
topic = message_type.email_topic(tournament.federal_level_category)
email_subject = TournamentEmailService.email_subject(tournament, topic)
TournamentEmailService._send_email(umpire_email, email_subject, email_body)
@staticmethod
def _build_payment_info(tournament, team_registration):
"""

@ -1,9 +1,8 @@
from django.contrib import messages
from django.utils import timezone
from ..models import PlayerRegistration, UnregisteredTeam, UnregisteredPlayer, PlayerPaymentType
from ..utils.licence_validator import LicenseValidator
from ..services.payment_service import PaymentService
from ..services.email_service import TournamentEmailService
from ..services.email_service import TournamentEmailService, TeamEmailType
class TournamentUnregistrationService:
def __init__(self, request, tournament):
@ -96,6 +95,8 @@ class TournamentUnregistrationService:
registered_online=player.registered_online
)
TournamentEmailService.notify_umpire(team_registration, team_registration.tournament, TeamEmailType.UNREGISTERED)
def _find_player_registration(self):
# First check if we can find the player registration directly by user
if self.request.user.is_authenticated:

@ -121,26 +121,32 @@
</div>
{% endif %}
{% if tournament.is_unregistration_possible %}
<div class="topmargin20">
{% if tournament.is_refund_possible and team.is_paid %}
<p class="minor info">
Si vous vous désinscrivez, votre inscription sera remboursée automatiquement sur votre carte bancaire.
{% if tournament.refund_date_limit %}
<div>Remboursement possible jusqu'au {{ tournament.refund_date_limit|date:"d/m/Y à H:i" }}</div>
{% endif %}
</p>
{% endif %}
<div style="margin-top: 40px;">
<a href="{% url 'unregister_tournament' tournament.id %}"
class="rounded-button destructive-button"
onclick="return confirm('Êtes-vous sûr de vouloir vous désinscrire ?{% if tournament.is_refund_possible and team.is_paid %} Votre inscription sera remboursée automatiquement.{% endif %}');">
{% if team.is_in_waiting_list >= 0 %}
Se retirer de la liste d'attente
{% else %}
Se désinscrire
{% if tournament.is_unregistration_possible and team.is_unregistration_possible %}
<div class="topmargin20">
{% if tournament.is_refund_possible and team.is_paid %}
<p class="minor info">
Si vous vous désinscrivez, votre inscription sera remboursée automatiquement sur votre carte bancaire.
{% if tournament.refund_date_limit %}
<div>Remboursement possible jusqu'au {{ tournament.refund_date_limit|date:"d/m/Y à H:i" }}</div>
{% endif %}
</a>
</p>
{% endif %}
<div style="margin-top: 40px;">
<a href="{% url 'unregister_tournament' tournament.id %}"
class="rounded-button destructive-button"
onclick="return confirm('Êtes-vous sûr de vouloir vous désinscrire ?{% if tournament.is_refund_possible and team.is_paid %} Votre inscription sera remboursée automatiquement.{% endif %}');">
{% if team.is_in_waiting_list >= 0 %}
Se retirer de la liste d'attente
{% else %}
Se désinscrire
{% endif %}
</a>
</div>
{% else %}
<div class="topmargin20">
<p class="minor info">
La désincription en ligne n'est plus possible. Veuillez contacter directement le juge-arbitre si besoin.
</p>
</div>
{% endif %}
</div>

Loading…
Cancel
Save