add live section

apikeys
Razmig Sarkissian 5 months ago
parent 41cda04ba9
commit 6483a0add2
  1. 26
      tournaments/templates/tournaments/live_matches.html
  2. 4
      tournaments/templates/tournaments/navigation_tournament.html
  3. 1
      tournaments/urls.py
  4. 21
      tournaments/views.py

@ -0,0 +1,26 @@
{% 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 %}
{% block title_link %}{% url 'tournament' tournament.id %}{% endblock %}
{% block content %}
{% include 'tournaments/navigation_tournament.html' %}
{% if live_matches %}
<h1 class="club padding10 topmargin20">En cours</h1>
<div class="grid-x">
{% for match in live_matches %}
{% include 'tournaments/match_cell.html' %}
{% endfor %}
</div>
{% else %}
<div class="grid-x">
<h1 class="club padding10 topmargin20">Aucun match en cours actuellement.</h1>
</div>
{% endif %}
{% endblock %}

@ -4,6 +4,10 @@
<a href="{% url 'tournament-info' tournament.id %}" class="topmargin5 orange">Informations</a> <a href="{% url 'tournament-info' tournament.id %}" class="topmargin5 orange">Informations</a>
{% if tournament.supposedly_in_progress %}
<a href="{% url 'tournament-live' tournament.id %}" class="topmargin5 orange">Live</a>
{% endif %}
{% if tournament.display_prog %} {% if tournament.display_prog %}
<a href="{% url 'tournament-prog' tournament.id %}" class="topmargin5 orange">Programmation</a> <a href="{% url 'tournament-prog' tournament.id %}" class="topmargin5 orange">Programmation</a>
{% endif %} {% endif %}

@ -45,6 +45,7 @@ urlpatterns = [
path('rankings/json/', views.tournament_rankings_json, name='tournament-rankings-json'), path('rankings/json/', views.tournament_rankings_json, name='tournament-rankings-json'),
path('broadcast/rankings/', views.tournament_broadcast_rankings, name='broadcasted-rankings'), path('broadcast/rankings/', views.tournament_broadcast_rankings, name='broadcasted-rankings'),
path('team/<str:team_id>/', views.team_details, name='team-details'), path('team/<str:team_id>/', views.team_details, name='team-details'),
path('live/', views.tournament_live_matches, name='tournament-live'),
]) ])
), ),
path("event/<str:event_id>/", views.event, name='event'), path("event/<str:event_id>/", views.event, name='event'),

@ -1782,6 +1782,27 @@ def private_tournaments(request):
} }
) )
def tournament_live_matches(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)
# Get all matches from the tournament
current_time = timezone.now()
matches = Match.objects.filter(
Q(round__tournament=tournament) | Q(group_stage__tournament=tournament),
start_date__isnull=False, # Match has a start date
start_date__lte=current_time,
confirmed=True, # Match is confirmed
end_date__isnull=True # Match hasn't ended yet
).order_by('start_date')
# Convert to live match format
live_matches = [match.live_match() for match in matches]
return render(request, 'tournaments/live_matches.html', {
'tournament': tournament,
'live_matches': live_matches,
})
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