-
+
diff --git a/tournaments/templates/tournaments/clubs.html b/tournaments/templates/tournaments/clubs.html
new file mode 100644
index 0000000..40d4a25
--- /dev/null
+++ b/tournaments/templates/tournaments/clubs.html
@@ -0,0 +1,32 @@
+{% extends 'tournaments/base.html' %}
+
+{% block head_title %}Clubs{% endblock %}
+{% block first_title %}Padel Club{% endblock %}
+{% block second_title %}Clubs{% endblock %}
+
+{% load static %}
+
+{% block content %}
+
+ {% include 'tournaments/navigation_base.html' %}
+
+ {% if clubs %}
+
+
+
+
+
+ {% for club in clubs %}
+
+ {% include 'tournaments/club_row.html' %}
+
+ {% endfor %}
+
+
+
+
+
+
+ {% endif %}
+
+{% endblock %}
diff --git a/tournaments/templates/tournaments/group_stages.html b/tournaments/templates/tournaments/group_stages.html
index c67edad..c931b47 100644
--- a/tournaments/templates/tournaments/group_stages.html
+++ b/tournaments/templates/tournaments/group_stages.html
@@ -6,7 +6,7 @@
{% block content %}
- {% include 'tournaments/tournament_navigation.html' %}
+ {% include 'tournaments/navigation_tournament.html' %}
{% for group_stage in group_stages %}
diff --git a/tournaments/templates/tournaments/matches.html b/tournaments/templates/tournaments/matches.html
index c8d7a3c..8e777cd 100644
--- a/tournaments/templates/tournaments/matches.html
+++ b/tournaments/templates/tournaments/matches.html
@@ -6,7 +6,7 @@
{% block content %}
-{% include 'tournaments/tournament_navigation.html' %}
+{% include 'tournaments/navigation_tournament.html' %}
{% if rounds or group_stages %}
+ {% if club %}
+ {{ tournament.name }}
+ {% else %}
{{ tournament.event.club.name }}:
{{ tournament.name }}
+ {% endif %}
{{ tournament.formatted_start_date }}
diff --git a/tournaments/templates/tournaments/tournaments.html b/tournaments/templates/tournaments/tournaments.html
index d3ada82..5009b2d 100644
--- a/tournaments/templates/tournaments/tournaments.html
+++ b/tournaments/templates/tournaments/tournaments.html
@@ -2,10 +2,17 @@
{% block head_title %}Tournois{% endblock %}
{% block first_title %}Padel Club{% endblock %}
-{% block second_title %}Tournois{% endblock %}
+{% block second_title %}
+{% if club %}
+ {{ club.name }}
+{% else %}
+ Tournois
+{% endif %}
+{% endblock %}
{% block content %}
+{% include 'tournaments/navigation_base.html' %}
{% if live or future %}
diff --git a/tournaments/urls.py b/tournaments/urls.py
index 1cd76b9..a09c9e8 100644
--- a/tournaments/urls.py
+++ b/tournaments/urls.py
@@ -4,6 +4,8 @@ from . import views
urlpatterns = [
path("", views.index, name="index"),
+ path("clubs/", views.clubs, name="clubs"),
+ path("clubs/
/", views.club, name="club"),
path("tournament//",
include([
path('', views.tournament, name='tournament'),
diff --git a/tournaments/views.py b/tournaments/views.py
index 71d6866..6a047c8 100644
--- a/tournaments/views.py
+++ b/tournaments/views.py
@@ -17,13 +17,32 @@ from rest_framework.generics import UpdateAPIView
from django.template import loader
from datetime import date
from django.http import JsonResponse
+from django.db.models import Q
import json
def index(request):
+
today = date.today()
- future_tournaments = Tournament.objects.filter(is_private=False, end_date__isnull=True, start_date__gt=today).order_by('start_date')
- live_tournaments = Tournament.objects.filter(is_private=False, end_date__isnull=True, start_date__lte=today).order_by('start_date')
- ended_tournaments = Tournament.objects.filter(is_private=False, end_date__isnull=False).order_by('start_date')
+
+ club_id = request.GET.get('club')
+ q_is_private = Q(is_private=False)
+
+ q_future = [q_is_private, Q(end_date__isnull=True, start_date__gt=today)]
+ q_live = [q_is_private, Q(end_date__isnull=True, start_date__lte=today)]
+ q_ended = [q_is_private, Q(end_date__isnull=False)]
+
+ club = None
+ if club_id:
+ club = get_object_or_404(Club, pk=club_id)
+
+ q_club = Q(event__club=club)
+ q_future.append(q_club)
+ q_live.append(q_club)
+ q_ended.append(q_club)
+
+ future_tournaments = Tournament.objects.filter(*q_future).order_by('start_date')
+ live_tournaments = Tournament.objects.filter(*q_live).order_by('start_date')
+ ended_tournaments = Tournament.objects.filter(*q_ended).order_by('start_date')
return render(
request,
"tournaments/tournaments.html",
@@ -31,9 +50,23 @@ def index(request):
'future': future_tournaments,
'live': live_tournaments,
'ended': ended_tournaments,
+ 'club': club,
}
)
+def clubs(request):
+ clubs = Club.objects.all().order_by('name')
+ return render(request, 'tournaments/clubs.html', {
+ 'clubs': clubs,
+ })
+
+def club(request, club_id):
+ club = get_object_or_404(Club, pk=club_id)
+ return render(request, 'tournaments/summons.html', {
+ 'tournament': tournament,
+ 'team_summons': team_summons,
+ })
+
def tournament(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)