Raz 8 months ago
commit e3a9d8ad06
  1. 3
      tournaments/models/match.py
  2. 12
      tournaments/models/round.py
  3. 11
      tournaments/models/tournament.py
  4. 3
      tournaments/services/email_service.py
  5. 2
      tournaments/templates/tournaments/matches.html

@ -59,7 +59,8 @@ class Match(SideStoreModel):
def court_name(self, index):
club = None
if self.tournament().event:
tournament = self.tournament()
if tournament and tournament.event:
club = self.tournament().event.club
if club:

@ -47,13 +47,19 @@ class Round(SideStoreModel):
if self.index == 0:
return "Finale"
elif self.index == 1:
return "Demis"
return "Demie"
elif self.index == 2:
return "Quarts"
return "Quart"
else:
squared = 2 ** self.index
return f"{squared}ème"
def plural_name(self):
name = self.name()
if self.parent is None and self.index > 0:
return f'{name}s'
return name
def ranking_matches(self, hide_empty_matches):
matches = []
for child in self.children.all():
@ -165,7 +171,7 @@ class Round(SideStoreModel):
if first_half_matches:
name = self.name()
name = self.plural_name()
if parent_round and first_half_matches[0].name is not None:
name = first_half_matches[0].name
match_group = self.tournament.create_match_group(

@ -534,7 +534,7 @@ class Tournament(BaseModel):
if round and matches:
matches.sort(key=lambda m: m.index)
group = self.create_match_group(round.name(), matches)
group = self.create_match_group(round.plural_name(), matches)
groups.append(group)
ranking_matches = round.ranking_matches(hide_empty_matches)
@ -1039,7 +1039,7 @@ class Tournament(BaseModel):
return plural_format("jour", self.day_duration)
def has_club_address(self):
if self.event.club:
if self.event and self.event.club:
return self.event.club.has_address()
else:
return False
@ -1471,10 +1471,13 @@ class Tournament(BaseModel):
else:
return True
def umpire_contact(self):
def umpire_contact(self):
if self.umpire_custom_contact is not None:
return self.umpire_custom_contact
return self.event.creator.full_name()
if self.event and self.event.creator:
return self.event.creator.full_name()
else:
return None
def umpire_mail(self):
if self.umpire_custom_mail is not None:

@ -342,7 +342,8 @@ class TournamentEmailService:
def _format_umpire_contact(tournament):
contact_parts = []
creator_full_name = tournament.umpire_contact()
contact_parts.append(creator_full_name)
if creator_full_name:
contact_parts.append(creator_full_name)
if not tournament.hide_umpire_mail:
creator_email = tournament.umpire_mail()

@ -21,7 +21,7 @@
{% endif %}
{% if tournament.display_matches %}
{% for round in rounds %}
<a href="{% url 'tournament' tournament.id %}?round={{ round.id }}" class="mybox topmargin5">{{ round.name }}</a>
<a href="{% url 'tournament' tournament.id %}?round={{ round.id }}" class="mybox topmargin5">{{ round.plural_name }}</a>
{% endfor %}
{% endif %}
</nav>

Loading…
Cancel
Save