From b5b5d4e0f5329101da5f1c1a92ef2eb147b57a44 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Sat, 21 Jun 2025 07:56:10 +0200 Subject: [PATCH] add event info and prog link if possible --- tournaments/models/tournament.py | 2 -- .../tournaments/tournament_info.html | 4 ++-- .../tournaments/tournaments_list.html | 20 ++++++++++++++++--- tournaments/views.py | 15 +++++++++++--- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 7c78b96..daf6520 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -911,8 +911,6 @@ class Tournament(BaseModel): return False def display_prog(self): - if self.end_date is not None: - return True if self.publish_prog: return True if self.has_started(): diff --git a/tournaments/templates/tournaments/tournament_info.html b/tournaments/templates/tournaments/tournament_info.html index d37e5eb..3613823 100644 --- a/tournaments/templates/tournaments/tournament_info.html +++ b/tournaments/templates/tournaments/tournament_info.html @@ -182,7 +182,7 @@

- +

{{ tournament.event.club.name }}
{% if tournament.has_club_address %}
{{ tournament.event.club.address }}
@@ -193,7 +193,7 @@ {% if tournament.event.tournaments.count > 1 %}

- +

Voir les autres tournois de l'événement{% if tournament.event.name %} {{ tournament.event.name }}{% endif %}

diff --git a/tournaments/templates/tournaments/tournaments_list.html b/tournaments/templates/tournaments/tournaments_list.html index 11060ac..784c0d6 100644 --- a/tournaments/templates/tournaments/tournaments_list.html +++ b/tournaments/templates/tournaments/tournaments_list.html @@ -7,12 +7,9 @@ {% block content %} {% include 'tournaments/navigation_base.html' %} -
- {% if tournaments %}
-
{% for tournament in tournaments %} @@ -23,6 +20,23 @@
{% endif %} + {% if first_tournament_prog_url and tournaments %} +
+
+ Voir la programmation de l'événement + {% if tournaments.first.information %} +
+

+

Infos
+
+ {{ tournaments.first.information|linebreaksbr|urlize }} +
+

+ {% endif %} +
+
+ {% endif %} +
{% endblock %} diff --git a/tournaments/views.py b/tournaments/views.py index c1f7cf4..4266566 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -258,18 +258,29 @@ def club(request, club_id): def event(request, event_id): event = get_object_or_404(Event, pk=event_id) + tournaments = event.tournaments.all().order_by('start_date') + + # Get the first tournament for the prog link + first_tournament_prog_url = None + if tournaments.exists(): + first_tournament = tournaments.first() + if first_tournament.display_prog(): + first_tournament_prog_url = reverse('tournament-prog', kwargs={'tournament_id': first_tournament.id}) + if event.name and len(event.name) > 0: name = event.name else: name = 'Événement' + return render( request, "tournaments/tournaments_list.html", { - 'tournaments': event.tournaments.all().order_by('start_date'), + 'tournaments': tournaments, 'first_title': event.club.name, 'second_title': name, 'head_title': name, + 'first_tournament_prog_url': first_tournament_prog_url, } ) @@ -1741,8 +1752,6 @@ def private_tournaments(request): False, 50 ) - print(tournaments) - # Filter tournaments that should be displayed display_tournament = tournaments