add prog view

bracket-feature^2
Razmig Sarkissian 8 months ago
parent 6a35b764a4
commit 5d0385c10c
  1. 10
      tournaments/models/match.py
  2. 40
      tournaments/templates/tournaments/prog.html
  3. 1
      tournaments/urls.py
  4. 27
      tournaments/views.py

@ -389,7 +389,7 @@ class Match(models.Model):
ended = self.end_date is not None ended = self.end_date is not None
live_format = "Format " + FederalMatchCategory(self.format).format_label_short live_format = "Format " + FederalMatchCategory(self.format).format_label_short
livematch = LiveMatch(title, date, time_indication, court, self.started(), ended, group_stage_name, live_format) livematch = LiveMatch(title, date, time_indication, court, self.started(), ended, group_stage_name, live_format, self.start_date, self.court_index)
for team in self.live_teams(): for team in self.live_teams():
livematch.add_team(team) livematch.add_team(team)
@ -446,7 +446,7 @@ class Team:
} }
class LiveMatch: class LiveMatch:
def __init__(self, title, date, time_indication, court, started, ended, group_stage_name, format): def __init__(self, title, date, time_indication, court, started, ended, group_stage_name, format, start_date, court_index):
self.title = title self.title = title
self.date = date self.date = date
self.teams = [] self.teams = []
@ -457,6 +457,8 @@ class LiveMatch:
self.has_walk_out = False self.has_walk_out = False
self.group_stage_name = group_stage_name self.group_stage_name = group_stage_name
self.format = format self.format = format
self.start_date = start_date
self.court_index = court_index
def add_team(self, team): def add_team(self, team):
self.teams.append(team) self.teams.append(team)
@ -474,7 +476,9 @@ class LiveMatch:
"ended": self.ended, "ended": self.ended,
"has_walk_out": self.has_walk_out, "has_walk_out": self.has_walk_out,
"group_stage_name": self.group_stage_name, "group_stage_name": self.group_stage_name,
"format": self.format "format": self.format,
"start_date": self.start_date,
"court_index": self.court_index
} }
def show_time_indication(self): def show_time_indication(self):

@ -0,0 +1,40 @@
{% extends 'tournaments/base.html' %}
{% block head_title %}Matchs du {{ tournament.display_name }}{% endblock %}
{% block first_title %}{{ tournament.event.display_name }}{% endblock %}
{% block second_title %}{{ tournament.display_name }}{% endblock %}
{% if tournament.display_matches %}
{% block content %}
{% include 'tournaments/navigation_tournament.html' %}
{% if tournament.display_matches or tournament.display_group_stages %}
{% regroup match_groups.matches by start_date|date:"l d F Y" as matches_by_date %}
{% for date in matches_by_date %}
{% regroup date.list by start_date|date:"H:i" as matches_by_hour %}
{% for hour_group in matches_by_hour %}
<h1 class="club my-block topmargin20">{{ date.grouper }} {{ hour_group.grouper }}</h1>
{% regroup hour_group.list by court_index as matches_by_court %}
<div class="grid-x">
{% for court in matches_by_court|dictsort:"grouper" %}
{% for match_data in court.list %}
{% with match=match_data.match %}
{% include 'tournaments/match_cell.html' %}
{% endwith %}
{% endfor %}
{% endfor %}
</div>
{% endfor %}
{% endfor %}
{% endif %}
{% endblock %}
{% endif %}

@ -17,6 +17,7 @@ urlpatterns = [
path('', views.tournament, name='tournament'), path('', views.tournament, name='tournament'),
path('teams/', views.tournament_teams, name='tournament-teams'), path('teams/', views.tournament_teams, name='tournament-teams'),
path('info/', views.tournament_info, name='tournament-info'), path('info/', views.tournament_info, name='tournament-info'),
path('prog/', views.tournament_prog, name='tournament-prog'),
path('summons/', views.tournament_summons, name='tournament-summons'), path('summons/', views.tournament_summons, name='tournament-summons'),
path('broadcast/summons/', views.tournament_broadcasted_summons, name='broadcasted-summons'), path('broadcast/summons/', views.tournament_broadcasted_summons, name='broadcasted-summons'),
path('summons/json/', views.tournament_summons_json, name='tournament-summons-json'), path('summons/json/', views.tournament_summons_json, name='tournament-summons-json'),

@ -954,6 +954,33 @@ def team_details(request, tournament_id, team_id):
'debug': False # Set to False in production 'debug': False # Set to False in production
}) })
def tournament_prog(request, tournament_id):
tournament = get_object_or_404(Tournament, id=tournament_id)
# Get matches from all_groups
match_groups = tournament.all_groups(broadcasted=False)
# Flatten matches and add necessary attributes
all_matches = []
for group in match_groups:
for match in group.matches:
if match.start_date: # Only include matches with start dates
all_matches.append({
'start_date': match.start_date,
'court_index': match.court_index,
# Add other match attributes needed for match_cell.html
'match': match
})
# Sort matches by date and court
all_matches.sort(key=lambda x: (x['start_date'], x['court_index'] or 999))
context = {
'tournament': tournament,
'match_groups': {'matches': all_matches}
}
return render(request, 'tournaments/prog.html', context)
class UserListExportView(LoginRequiredMixin, View): class UserListExportView(LoginRequiredMixin, View):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
users = CustomUser.objects.order_by('date_joined') users = CustomUser.objects.order_by('date_joined')

Loading…
Cancel
Save