From f55d123cbf35a6fc7829756db9de9f8118cae080 Mon Sep 17 00:00:00 2001 From: Raz Date: Wed, 26 Mar 2025 11:19:10 +0100 Subject: [PATCH 1/2] add custom contact management and special rank ruling --- ...artitem_options_alter_orderitem_options.py | 21 +++++++++ ...disable_ranking_federal_ruling_and_more.py | 43 +++++++++++++++++++ tournaments/models/tournament.py | 24 +++++++++++ tournaments/services/email_service.py | 38 +++++++++++----- .../tournaments/tournament_info.html | 12 ++++-- tournaments/utils/extensions.py | 1 + 6 files changed, 126 insertions(+), 13 deletions(-) create mode 100644 shop/migrations/0022_alter_cartitem_options_alter_orderitem_options.py create mode 100644 tournaments/migrations/0112_tournament_disable_ranking_federal_ruling_and_more.py diff --git a/shop/migrations/0022_alter_cartitem_options_alter_orderitem_options.py b/shop/migrations/0022_alter_cartitem_options_alter_orderitem_options.py new file mode 100644 index 0000000..8cbada4 --- /dev/null +++ b/shop/migrations/0022_alter_cartitem_options_alter_orderitem_options.py @@ -0,0 +1,21 @@ +# Generated by Django 5.1 on 2025-03-26 08:47 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('shop', '0021_alter_color_name_alter_product_sku'), + ] + + operations = [ + migrations.AlterModelOptions( + name='cartitem', + options={'ordering': ['product__ordering_value', 'product__cut']}, + ), + migrations.AlterModelOptions( + name='orderitem', + options={'ordering': ['product__ordering_value', 'product__cut']}, + ), + ] diff --git a/tournaments/migrations/0112_tournament_disable_ranking_federal_ruling_and_more.py b/tournaments/migrations/0112_tournament_disable_ranking_federal_ruling_and_more.py new file mode 100644 index 0000000..8d339c7 --- /dev/null +++ b/tournaments/migrations/0112_tournament_disable_ranking_federal_ruling_and_more.py @@ -0,0 +1,43 @@ +# Generated by Django 5.1 on 2025-03-26 10:16 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tournaments', '0111_customuser_should_synchronize'), + ] + + operations = [ + migrations.AddField( + model_name='tournament', + name='disable_ranking_federal_ruling', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='tournament', + name='hide_umpire_mail', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='tournament', + name='hide_umpire_phone', + field=models.BooleanField(default=True), + ), + migrations.AddField( + model_name='tournament', + name='umpire_custom_contact', + field=models.CharField(blank=True, max_length=200, null=True), + ), + migrations.AddField( + model_name='tournament', + name='umpire_custom_mail', + field=models.EmailField(blank=True, max_length=254, null=True), + ), + migrations.AddField( + model_name='tournament', + name='umpire_custom_phone', + field=models.CharField(blank=True, max_length=15, null=True), + ), + ] diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 77dc6a5..77e6711 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -75,6 +75,12 @@ class Tournament(BaseModel): minimum_player_per_team = models.IntegerField(default=2) maximum_player_per_team = models.IntegerField(default=2) information = models.CharField(max_length=4000, null=True, blank=True) + umpire_custom_mail = models.EmailField(null=True, blank=True) + umpire_custom_contact = models.CharField(max_length=200, null=True, blank=True) + umpire_custom_phone = models.CharField(max_length=15, null=True, blank=True) + hide_umpire_mail = models.BooleanField(default=False) + hide_umpire_phone = models.BooleanField(default=True) + disable_ranking_federal_ruling = models.BooleanField(default=False) def delete_dependencies(self): for team_registration in self.team_registrations.all(): @@ -1410,6 +1416,24 @@ class Tournament(BaseModel): else: return True + def umpire_contact(self): + if self.umpire_custom_contact is not None: + print(self.umpire_custom_contact) + return self.umpire_custom_contact + return self.event.creator.full_name() + + def umpire_mail(self): + if self.umpire_custom_mail is not None: + print(self.umpire_custom_mail) + return self.umpire_custom_mail + return self.event.creator.email + + def umpire_phone(self): + if self.umpire_custom_phone is not None: + print(self.umpire_custom_phone) + return self.umpire_custom_phone + return self.event.creator.phone + class MatchGroup: def __init__(self, name, matches, formatted_schedule, round_id=None): diff --git a/tournaments/services/email_service.py b/tournaments/services/email_service.py index 2f370de..6a3a59d 100644 --- a/tournaments/services/email_service.py +++ b/tournaments/services/email_service.py @@ -85,7 +85,7 @@ class TournamentEmailService: f"\nLe tournoi commencera le {tournament.formatted_start_date()} au club {tournament.event.club.name}", f"\nVoir les {absolute_url}", "\nPour toute question, veuillez contacter votre juge-arbitre. Si vous n'êtes pas à l'origine de cette inscription, merci de le contacter rapidement.", - f"\n{tournament.event.creator.full_name()}\n{tournament.event.creator.email}", + f"\n{TournamentEmailService._format_umpire_contact(tournament)}", "\nCeci est un e-mail automatique, veuillez ne pas y répondre.", "\nCordialement,\n\nPadel Club" ]) @@ -115,7 +115,7 @@ class TournamentEmailService: body_parts.extend([ "\n\nPour toute question, veuillez contacter votre juge-arbitre. " "Si vous n'êtes pas à l'origine de cette désinscription, merci de le contacter rapidement.", - f"\n{tournament.event.creator.full_name()}\n{tournament.event.creator.email}", + f"\n{TournamentEmailService._format_umpire_contact(tournament)}", "\n\nCeci est un e-mail automatique, veuillez ne pas y répondre." ]) @@ -144,7 +144,7 @@ class TournamentEmailService: ) body_parts.extend([ - f"\n\n{tournament.event.creator.full_name()}\n{tournament.event.creator.email}", + f"\n\n{TournamentEmailService._format_umpire_contact(tournament)}", "\n\nCeci est un e-mail automatique, veuillez ne pas y répondre." ]) @@ -164,7 +164,7 @@ class TournamentEmailService: body_parts.extend([ "\n\nPour toute question, veuillez contacter votre juge-arbitre:", - f"\n{tournament.event.creator.full_name()}\n{tournament.event.creator.email}", + f"\n{TournamentEmailService._format_umpire_contact(tournament)}", "\n\nCeci est un e-mail automatique, veuillez ne pas y répondre." ]) @@ -193,7 +193,7 @@ class TournamentEmailService: ) body_parts.extend([ - f"\n\n{tournament.event.creator.full_name()}\n{tournament.event.creator.email}", + f"\n\n{TournamentEmailService._format_umpire_contact(tournament)}", "\n\nCeci est un e-mail automatique, veuillez ne pas y répondre." ]) @@ -219,7 +219,7 @@ class TournamentEmailService: body_parts.extend([ "\n\nPour toute question, veuillez contacter votre juge-arbitre : ", - f"\n{tournament.event.creator.full_name()}\n{tournament.event.creator.email}", + f"\n{TournamentEmailService._format_umpire_contact(tournament)}", "\n\nCeci est un e-mail automatique, veuillez ne pas y répondre." ]) @@ -246,7 +246,7 @@ class TournamentEmailService: body_parts.extend([ "\n\nPour toute question, veuillez contacter votre juge-arbitre : ", - f"\n{tournament.event.creator.full_name()}\n{tournament.event.creator.email}", + f"\n{TournamentEmailService._format_umpire_contact(tournament)}", "\n\nCeci est un e-mail automatique, veuillez ne pas y répondre." ]) @@ -272,7 +272,7 @@ class TournamentEmailService: body_parts.extend([ "\n\nPour toute question, veuillez contacter votre juge-arbitre : ", - f"\n{tournament.event.creator.full_name()}\n{tournament.event.creator.email}", + f"\n{TournamentEmailService._format_umpire_contact(tournament)}", "\n\nCeci est un e-mail automatique, veuillez ne pas y répondre." ]) @@ -298,7 +298,7 @@ class TournamentEmailService: body_parts.extend([ "\n\nPour toute question, veuillez contacter votre juge-arbitre : ", - f"\n{tournament.event.creator.full_name()}\n{tournament.event.creator.email}", + f"\n{TournamentEmailService._format_umpire_contact(tournament)}", "\n\nCeci est un e-mail automatique, veuillez ne pas y répondre." ]) @@ -324,12 +324,30 @@ class TournamentEmailService: body_parts.extend([ "\n\nPour toute question, veuillez contacter votre juge-arbitre : ", - f"\n{tournament.event.creator.full_name()}\n{tournament.event.creator.email}", + f"\n{TournamentEmailService._format_umpire_contact(tournament)}", "\n\nCeci est un e-mail automatique, veuillez ne pas y répondre." ]) return "".join(body_parts) + @staticmethod + def _format_umpire_contact(tournament): + contact_parts = [] + creator_full_name = tournament.umpire_contact() + contact_parts.append(creator_full_name) + + if not tournament.hide_umpire_mail: + creator_email = tournament.umpire_mail() + if creator_email: + contact_parts.append(creator_email) + + if not tournament.hide_umpire_phone: + creator_phone = tournament.umpire_phone() + if creator_phone: + contact_parts.append(creator_phone) + + return "\n".join(contact_parts) + @staticmethod def notify(captain, other_player, tournament, message_type: TeamEmailType): print("TournamentEmailService.notify", captain.email, captain.registered_online, tournament, message_type) diff --git a/tournaments/templates/tournaments/tournament_info.html b/tournaments/templates/tournaments/tournament_info.html index 4e0a7ea..9c93a55 100644 --- a/tournaments/templates/tournaments/tournament_info.html +++ b/tournaments/templates/tournaments/tournament_info.html @@ -90,12 +90,18 @@ {% endif %}

- {% if tournament.event.creator %}

+ {% if tournament.umpire_contact %}

Organisateur
-
{{ tournament.event.creator.full_name }}
+
{{ tournament.umpire_contact }}
+ {% endif %} + {% if tournament.umpire_mail and tournament.hide_umpire_mail is False %} +
{{ tournament.umpire_mail }}
+ {% endif %} + {% if tournament.umpire_phone and tournament.hide_umpire_phone is False %} +
{{ tournament.umpire_phone }}
+ {% endif %}

- {% endif %} {% if tournament.information %}

diff --git a/tournaments/utils/extensions.py b/tournaments/utils/extensions.py index fed47b1..047a1ee 100644 --- a/tournaments/utils/extensions.py +++ b/tournaments/utils/extensions.py @@ -17,5 +17,6 @@ def create_random_filename(base_name, extension): return f"{base_name}_{random_string}.{extension}" def is_not_sqlite_backend(): + return True default_db_engine = settings.DATABASES['default']['ENGINE'] return default_db_engine != 'django.db.backends.sqlite3' From f77aff3237a4026d923e60a2635209907122a3d8 Mon Sep 17 00:00:00 2001 From: Raz Date: Wed, 26 Mar 2025 19:01:02 +0100 Subject: [PATCH 2/2] fix css --- tournaments/models/match.py | 2 +- tournaments/static/tournaments/css/style.css | 7 ++++--- tournaments/templates/tournaments/bracket_match_cell.html | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tournaments/models/match.py b/tournaments/models/match.py index bb23a2e..15194b8 100644 --- a/tournaments/models/match.py +++ b/tournaments/models/match.py @@ -428,7 +428,7 @@ class Match(SideStoreModel): if self.group_stage: group_stage_name = self.group_stage.display_name() else: - bracket_name = f"Match n˚{self.index_in_round() + 1}" + bracket_name = "Match #" + f"{self.index_in_round() + 1}" ended = self.end_date is not None live_format = "Format " + FederalMatchCategory(self.format).format_label_short diff --git a/tournaments/static/tournaments/css/style.css b/tournaments/static/tournaments/css/style.css index b287a0b..82b4f40 100644 --- a/tournaments/static/tournaments/css/style.css +++ b/tournaments/static/tournaments/css/style.css @@ -904,17 +904,18 @@ h-margin { .status-container-bracket { margin: 0px -20px -20px -20px; /* Negative margin to counter the bubble padding, including bottom */ - padding: 10px 20px 20px 20px; /* Add padding back to maintain text alignment, including bottom */ + padding: 10px 20px 10px 20px; /* Add padding back to maintain text alignment, including bottom */ border-radius: 0 0 24px 24px; /* Match the bubble's bottom corners */ + align-items: center; } .status-container-bracket-header { - height: 30px; + height: 24px; text-align: left; } .status-container-bracket-header-bottom { - height: 30px; + height: 24px; text-align: left; } diff --git a/tournaments/templates/tournaments/bracket_match_cell.html b/tournaments/templates/tournaments/bracket_match_cell.html index 33a3bbc..625f7ce 100644 --- a/tournaments/templates/tournaments/bracket_match_cell.html +++ b/tournaments/templates/tournaments/bracket_match_cell.html @@ -3,7 +3,7 @@

-
+
{% if match.bracket_name %} {% endif %}