fix dashboard and long cells date

apikeys
Razmig Sarkissian 5 months ago
parent 882302ab4e
commit cfc10d0e24
  1. 38
      tournaments/models/match.py
  2. 2
      tournaments/models/tournament.py
  3. 60
      tournaments/templates/admin/tournaments/dashboard.html

@ -330,16 +330,35 @@ class Match(TournamentSubModel):
else:
return 'À suivre'
else:
# timezoned_datetime = timezone.localtime(self.start_date)
timezone = self.get_tournament().timezone()
# Get the tournament and timezone
tournament = self.get_tournament()
timezone = tournament.timezone()
local_start = self.start_date.astimezone(timezone)
time_format ='l H:i'
if self.get_tournament().day_duration >= 7:
time_format = 'l d M à H:i'
if tournament.day_duration >= 7:
# Use the custom month property from tournament
# First create a date object with the same date as local_start
# so we can use tournament's week_day and month properties
# Format the hour and minute
hour = local_start.hour
minute = local_start.minute
time_str = f"{hour:02d}:{minute:02d}"
# Create the formatted date string using tournament properties and local_start
weekday = formats.date_format(local_start, format='D') + '.' # Abbreviated weekday with period
day = local_start.day
month = tournament.month # Use the custom month property
formatted_date = f"{weekday} {day} {month} à {time_str}"
else:
# For shorter durations, just use the weekday and time
formatted_date = formats.date_format(local_start, format='l H:i')
if self.confirmed:
return formats.date_format(local_start, format=time_format)
return formatted_date
else:
return f"Estimée : {formats.date_format(local_start, format=time_format)}"
return f"Estimée : {formatted_date}"
else:
return 'À venir...'
@ -460,7 +479,10 @@ class Match(TournamentSubModel):
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
live_format = "Format "
if self.get_tournament().day_duration >= 7:
live_format = ""
live_format = live_format + FederalMatchCategory(self.format).format_label_short
tournament_title = None
if event_mode is True:

@ -596,7 +596,7 @@ class Tournament(BaseModel):
# Format the date
timezone = first_match.get_tournament().timezone()
local_start = first_match.start_date.astimezone(timezone)
time_format = 'l d M'
time_format = 'l d F'
formatted_schedule = f" - {formats.date_format(local_start, format=time_format)}"
return MatchGroup(name, live_matches, formatted_schedule, round_id, round_index)

@ -13,7 +13,35 @@
{% block content %}
<div class="tournament-dashboard">
<h1>🏆 Tournament Dashboard</h1>
<!-- Quick Actions - Déplacé en haut -->
<div class="quick-actions" style="background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 12px; padding: 25px; margin-bottom: 20px;">
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px;">
<a href="{% url 'admin:tournaments_tournament_changelist' %}"
style="display: block; padding: 12px 15px; background: #007bff; color: white; text-decoration: none; border-radius: 8px; text-align: center; font-weight: 500;">
Tournaments
</a>
<a href="{% url 'admin:tournaments_teamregistration_changelist' %}"
style="display: block; padding: 12px 15px; background: #28a745; color: white; text-decoration: none; border-radius: 8px; text-align: center; font-weight: 500;">
Teams
</a>
<a href="{% url 'admin:tournaments_playerregistration_changelist' %}"
style="display: block; padding: 12px 15px; background: #6c757d; color: white; text-decoration: none; border-radius: 8px; text-align: center; font-weight: 500;">
Players
</a>
<a href="{% url 'admin:tournaments_match_changelist' %}"
style="display: block; padding: 12px 15px; background: #fd7e14; color: white; text-decoration: none; border-radius: 8px; text-align: center; font-weight: 500;">
Matches
</a>
<a href="{% url 'admin:tournaments_event_changelist' %}"
style="display: block; padding: 12px 15px; background: #17a2b8; color: white; text-decoration: none; border-radius: 8px; text-align: center; font-weight: 500;">
Events
</a>
<a href="{% url 'admin:tournaments_club_changelist' %}"
style="display: block; padding: 12px 15px; background: #ffc107; color: #212529; text-decoration: none; border-radius: 8px; text-align: center; font-weight: 500;">
Clubs
</a>
</div>
</div>
<!-- Summary Statistics Cards -->
<div class="dashboard-stats" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin: 20px 0;">
@ -377,36 +405,6 @@
</div>
</div>
<!-- Quick Actions -->
<div class="quick-actions" style="background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 12px; padding: 25px; margin-top: 20px;">
<h3 style="margin: 0 0 20px 0; color: #495057;">🚀 Quick Actions</h3>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px;">
<a href="{% url 'admin:tournaments_tournament_changelist' %}"
style="display: block; padding: 12px 15px; background: #007bff; color: white; text-decoration: none; border-radius: 8px; text-align: center; font-weight: 500;">
View All Tournaments
</a>
<a href="{% url 'admin:tournaments_teamregistration_changelist' %}"
style="display: block; padding: 12px 15px; background: #28a745; color: white; text-decoration: none; border-radius: 8px; text-align: center; font-weight: 500;">
Manage Teams
</a>
<a href="{% url 'admin:tournaments_playerregistration_changelist' %}"
style="display: block; padding: 12px 15px; background: #6c757d; color: white; text-decoration: none; border-radius: 8px; text-align: center; font-weight: 500;">
Manage Players
</a>
<a href="{% url 'admin:tournaments_match_changelist' %}"
style="display: block; padding: 12px 15px; background: #fd7e14; color: white; text-decoration: none; border-radius: 8px; text-align: center; font-weight: 500;">
View Matches
</a>
<a href="{% url 'admin:tournaments_event_changelist' %}"
style="display: block; padding: 12px 15px; background: #17a2b8; color: white; text-decoration: none; border-radius: 8px; text-align: center; font-weight: 500;">
Manage Events
</a>
<a href="{% url 'admin:tournaments_club_changelist' %}"
style="display: block; padding: 12px 15px; background: #ffc107; color: #212529; text-decoration: none; border-radius: 8px; text-align: center; font-weight: 500;">
Manage Clubs
</a>
</div>
</div>
</div>
<style>

Loading…
Cancel
Save