diff --git a/scores/models.py b/scores/models.py index f04b16a..929aafc 100644 --- a/scores/models.py +++ b/scores/models.py @@ -19,6 +19,9 @@ class Tournament(models.Model): def __str__(self): return self.name + def brackets(self): + return self.matches.filter(isBracket=True).order_by('court') + def live_matches(self): return self.matches.filter(enddate__isnull=True).order_by('court') diff --git a/scores/templates/scores/brackets.html b/scores/templates/scores/brackets.html new file mode 100644 index 0000000..fb89906 --- /dev/null +++ b/scores/templates/scores/brackets.html @@ -0,0 +1,180 @@ + + +{% load static %} + + + {% if tv %} + + + + {% endif %} + + + Padel + {% if not tv %} + + {% endif %} + + +
+ {% if tv %} + + {% endif %} + + {% if tournament.club.header %} + {% if tv %} +
{{ tournament.club.header }}
+{% else %} +
{{ tournament.club.header }}
+{% endif %} + {% endif %} + +
+ {% autoescape off %} + +
+
+ {% if tv %} +

{{ tournament.name }}

+ {% else %} +

{{ tournament.name }}

+ {% endif %} + +
+ {% if tv %} +

Classement | Équipes

+ {% else %} +

Classement | Équipes

+ {% endif %} +
+
+ {% for match in brackets %} + {% if match.isBracket %} +
+
+
+

{{ match.title|default:"Match" }}

+
+ +
+ {% if match.team3 %} + + + + {% if match.team1scorecolumn1 %}{% endif %} + {% if match.team2scorecolumn1 %}{% endif %} + + + {% if match.team1scorecolumn2 %}{% endif %} + {% if match.team2scorecolumn2 %}{% endif %} + + + {% if match.team1scorecolumn3 %}{% endif %} + {% if match.team2scorecolumn3 %}{% endif %} + + + {% if match.team1scorecolumn4 %}{% endif %} + {% if match.team2scorecolumn4 %}{% endif %} + + + {% if match.team5 %} + + + {% if match.team1scorecolumn5 %}{% endif %} + {% if match.team2scorecolumn5 %}{% endif %} + + {% endif %} + +
{{ match.team1|linebreaksbr }}{{ match.team1scorecolumn1 }}{{ match.team2scorecolumn1 }}
{{ match.team2|linebreaksbr }}{{ match.team1scorecolumn2 }}{{ match.team2scorecolumn2 }}
{{ match.team3|linebreaksbr }}{{ match.team1scorecolumn3 }}{{ match.team2scorecolumn3 }}
{{ match.team4|linebreaksbr }}{{ match.team1scorecolumn4 }}{{ match.team2scorecolumn4 }}
{{ match.team5|linebreaksbr }}{{ match.team1scorecolumn5 }}{{ match.team2scorecolumn5 }}
+ {% else %} + + + + + {% if match.team1scorecolumn1 %}{% endif %} + {% if match.team1scorecolumn2 %}{% endif %} + {% if match.team1scorecolumn3 %}{% endif %} + {% if match.team1scorecolumn4 %}{% endif %} + {% if match.team1scorecolumn5 %}{% endif %} + + + + {% if match.team2scorecolumn1 %}{% endif %} + {% if match.team2scorecolumn2 %}{% endif %} + {% if match.team2scorecolumn3 %}{% endif %} + {% if match.team2scorecolumn4 %}{% endif %} + {% if match.team2scorecolumn5 %}{% endif %} + +
{{ match.team1|linebreaksbr }}{{ match.team1scorecolumn1 }}{{ match.team1scorecolumn2 }}{{ match.team1scorecolumn3 }}{{ match.team1scorecolumn4 }}{{ match.team1scorecolumn5 }}
{{ match.team2|linebreaksbr }}{{ match.team2scorecolumn1 }}{{ match.team2scorecolumn2 }}{{ match.team2scorecolumn3 }}{{ match.team2scorecolumn4 }}{{ match.team2scorecolumn5 }}
+ + {% endif %} + + + {% if not match.isStatistic %} +

+

{{ match.durationPrefix }}
+
{{ match.duration }}
+

+ {% endif %} + +
+ {% endif %} + {% endfor %} + +
+ {% endautoescape %} +
+ + {% if club.footer %} + + {% endif %} + +
+ + diff --git a/scores/templates/scores/club.html b/scores/templates/scores/club.html index 03c7b3e..a952493 100644 --- a/scores/templates/scores/club.html +++ b/scores/templates/scores/club.html @@ -23,9 +23,9 @@
diff --git a/scores/templates/scores/ranks.html b/scores/templates/scores/ranks.html index 3fee650..0ca49e1 100644 --- a/scores/templates/scores/ranks.html +++ b/scores/templates/scores/ranks.html @@ -78,9 +78,9 @@ {% autoescape off %}
{% if tv %} -

{{ tournament.name }} +

{{ tournament.name }}

{% else %} -

{{ tournament.name }} +

{{ tournament.name }}

{% endif %}
diff --git a/scores/templates/scores/teams.html b/scores/templates/scores/teams.html index 728acb8..b59705e 100644 --- a/scores/templates/scores/teams.html +++ b/scores/templates/scores/teams.html @@ -78,9 +78,9 @@ {% autoescape off %}
{% if tv %} -

{{ tournament.name }} +

{{ tournament.name }}

{% else %} -

{{ tournament.name }} +

{{ tournament.name }}

{% endif %}
diff --git a/scores/templates/scores/tournament.html b/scores/templates/scores/tournament.html index 537aab2..6270ae2 100644 --- a/scores/templates/scores/tournament.html +++ b/scores/templates/scores/tournament.html @@ -66,7 +66,11 @@ {% endif %} {% if tournament.club.header %} -
{{ tournament.club.header }}
+ {% if tv %} +
{{ tournament.club.header }}
+ {% else %} +
{{ tournament.club.header }}
+ {% endif %} {% endif %}
@@ -76,14 +80,15 @@

{{ tournament.name }}

- {% if tv %} -

{{ tournament.name }} | Classement | Équipes

- {% else %} -

{{ tournament.name }} | Classement | Équipes

- {% endif %} + {% if tv %} +

Classement | Équipes | Poules

+ {% else %} +

Classement | Équipes | Poules

+ {% endif %}
{% for match in live_matches %} + {% if not match.isBracket %}
@@ -169,16 +174,37 @@ {% endif %}
+ {% endif %} {% endfor %} {% for match in ended_matches %} + {% if not match.isBracket %}
-
-
-

{{ match.title|default:"Match" }}

-
+
+
+

{{ match.title|default:"Match" }}

+ {% if match.isMatch or match.isBracket %} + {% if match.isMatch %} + + {% else %} + + {% endif %} + {% else %} + {% if match.isStatistic %} + + {% endif %} + + {% endif %} +
+ {% if match.team3 %} @@ -240,6 +266,7 @@ {% endif %}
+ {% endif %} {% endfor %}
diff --git a/scores/urls.py b/scores/urls.py index 197b8b0..db3ad72 100644 --- a/scores/urls.py +++ b/scores/urls.py @@ -19,6 +19,13 @@ from django.urls import path from . import views urlpatterns = [ + + path('tv/club///poules/', views.tv_brackets, name='brackets'), + path('club///poules/', views.brackets, name='brackets'), + path('tv/club//tournoi//poules/', views.tv_brackets_tournament_id, name='brackets'), + path('club//tournoi//poules/', views.brackets_tournament_id, name='brackets'), + + path('tv/club///classement/', views.tv_ranking, name='ranks'), path('club///classement/', views.ranking, name='ranks'), path('tv/club//tournoi//classement/', views.tv_ranking_tournament_id, name='ranks'), diff --git a/scores/views.py b/scores/views.py index b831d91..c3ede1f 100644 --- a/scores/views.py +++ b/scores/views.py @@ -223,6 +223,51 @@ def ranking(request, club_name, tournament_shortname): } return HttpResponse(template.render(context, request)) +def brackets_tournament_id(request, club_name, tournament_id): + tournament = get_object_or_404(Tournament, pk=tournament_id) + template = loader.get_template('scores/brackets.html') + allBrackets = Match.objects.filter(tournament=tournament.id).order_by('court') + context = { + 'tournament': tournament, + 'brackets': allBrackets, + } + return HttpResponse(template.render(context, request)) + +def tv_brackets_tournament_id(request, club_name, tournament_id): + tournament = get_object_or_404(Tournament, pk=tournament_id) + template = loader.get_template('scores/brackets.html') + allBrackets = Match.objects.filter(tournament=tournament.id).order_by('court') + context = { + 'tournament': tournament, + 'brackets': allBrackets, + 'tv': True, + } + return HttpResponse(template.render(context, request)) + + +def tv_brackets(request, club_name, tournament_shortname): + club = get_object_or_404(Club, name__iexact=club_name.lower()) + tournament = Tournament.objects.filter(club_id=club.id, shortname__iexact=tournament_shortname.lower()).first() + template = loader.get_template('scores/brackets.html') + allBrackets = Match.objects.filter(tournament=tournament.id).order_by('court') + context = { + 'tournament': tournament, + 'brackets': allBrackets, + 'tv': True, + } + return HttpResponse(template.render(context, request)) + +def brackets(request, club_name, tournament_shortname): + club = get_object_or_404(Club, name__iexact=club_name.lower()) + tournament = Tournament.objects.filter(club_id=club.id, shortname__iexact=tournament_shortname.lower()).first() + template = loader.get_template('scores/brackets.html') + allBrackets = Match.objects.filter(tournament=tournament.id).order_by('court') + context = { + 'tournament': tournament, + 'brackets': allBrackets, + } + return HttpResponse(template.render(context, request)) + class UserViewSet(viewsets.ModelViewSet): """ API endpoint that allows users to be viewed or edited.