diff --git a/scores/migrations/0021_team_position_finale.py b/scores/migrations/0021_team_position_finale.py new file mode 100644 index 0000000..4521f27 --- /dev/null +++ b/scores/migrations/0021_team_position_finale.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2 on 2023-07-31 11:34 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('scores', '0020_match_haswalkoutteam'), + ] + + operations = [ + migrations.AddField( + model_name='team', + name='position_finale', + field=models.IntegerField(default=0), + ), + ] diff --git a/scores/models.py b/scores/models.py index 64346bb..4e3da78 100644 --- a/scores/models.py +++ b/scores/models.py @@ -27,7 +27,9 @@ class Tournament(models.Model): def teams(self): return self.team_set.order_by('position') - + def teamsByFinalRank(self): + return self.team_set.order_by('position_finale').filter(position_finale__gt=0) + class Match(models.Model): tournament = models.ForeignKey(Tournament, on_delete=models.CASCADE, default=None) date = models.DateTimeField('start date') @@ -115,6 +117,7 @@ class Team(models.Model): name = models.CharField(max_length=200, blank=True) rank = models.IntegerField(default=0) position = models.IntegerField(default=0) + position_finale = models.IntegerField(default=0) bracket = models.BooleanField(default=False) position_label = models.CharField(max_length=200, blank=True) date_label = models.CharField(max_length=200, blank=True) diff --git a/scores/serializers.py b/scores/serializers.py index 6feaff4..31dd1fe 100644 --- a/scores/serializers.py +++ b/scores/serializers.py @@ -28,5 +28,5 @@ class MatchSerializer(serializers.HyperlinkedModelSerializer): class TeamSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Team - fields = ['id', 'name', 'background_color', 'rank', 'position', 'bracket', 'position_label', 'date_label', 'tournament'] + fields = ['id', 'name', 'background_color', 'rank', 'position', 'position_finale', 'bracket', 'position_label', 'date_label', 'tournament'] diff --git a/scores/templates/scores/ranks.html b/scores/templates/scores/ranks.html new file mode 100644 index 0000000..65fd631 --- /dev/null +++ b/scores/templates/scores/ranks.html @@ -0,0 +1,120 @@ + + +{% load static %} + + + {% if tv %} + + + + {% endif %} + + + Padel + +{% if tv %} +
+{% else %} +
+{% 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 %} +

+ +
+
+

Classement

+ + + + + + + + {% for team in tournament.teamsByFinalRank %} + + + + + + + + {% endfor %} +
ClassementNomPoidsRang initial
#{{ team.position_finale }}{{ team.name|linebreaksbr }}{{ team.rank }}{{ team.position }}
+ +

+ +
+ {% endautoescape %} +
+ + {% if tournament.club.footer %} +
{{ tournament.club.footer }}
+ {% endif %} + +
+ + diff --git a/scores/templates/scores/teams.html b/scores/templates/scores/teams.html index 7cc0247..728acb8 100644 --- a/scores/templates/scores/teams.html +++ b/scores/templates/scores/teams.html @@ -13,7 +13,6 @@ Padel - {% if tv %}
@@ -27,7 +26,13 @@ var iInterval = 2000; var iScrollInterval = 10000; var iFadeInterval = 500; - + var iScroll = $(document).height() - $(window).height(); + + if (iScroll * 10 + 4000 < 15000) { + iScrollInterval = 10000; + } else { + iScrollInterval = iScroll * 10; + } var fade = function() { $("body").fadeOut(iFadeInterval, function(){ $("html, body").scrollTop(0); @@ -39,6 +44,11 @@ var loop = function() { var iScroll = $(document).height() - $(window).height(); + if (iScroll * 10 + 4000 < 15000) { + iScrollInterval = 10000; + } else { + iScrollInterval = iScroll * 10; + } $("html, body").animate({ scrollTop: iScroll }, { @@ -48,9 +58,12 @@ setTimeout(fade, iInterval); } }); + setTimeout(function(){ + window.location.reload(); + }, Math.max(iScrollInterval * 10 + 2000, 15000)); }; setTimeout(loop, iInterval); - + {% endif %} {% if tournament.club.header %} diff --git a/scores/templates/scores/tournament.html b/scores/templates/scores/tournament.html index 44bdf9c..77481ec 100644 --- a/scores/templates/scores/tournament.html +++ b/scores/templates/scores/tournament.html @@ -11,9 +11,11 @@ {% endif %} - - Padel - + + Padel + {% if not tv %} + + {% endif %}}
@@ -23,7 +25,13 @@ var iInterval = 2000; var iScrollInterval = 10000; var iFadeInterval = 500; - + var iScroll = $(document).height() - $(window).height(); + + if (iScroll * 10 + 4000 < 15000) { + iScrollInterval = 10000; + } else { + iScrollInterval = iScroll * 10; + } var fade = function() { $("body").fadeOut(iFadeInterval, function(){ $("html, body").scrollTop(0); @@ -35,6 +43,11 @@ var loop = function() { var iScroll = $(document).height() - $(window).height(); + if (iScroll * 10 + 4000 < 15000) { + iScrollInterval = 10000; + } else { + iScrollInterval = iScroll * 10; + } $("html, body").animate({ scrollTop: iScroll }, { @@ -44,6 +57,9 @@ setTimeout(fade, iInterval); } }); + setTimeout(function(){ + window.location.reload(); + }, Math.max(iScrollInterval * 10 + 2000, 15000)); }; setTimeout(loop, iInterval); diff --git a/scores/urls.py b/scores/urls.py index 131d18c..56a9205 100644 --- a/scores/urls.py +++ b/scores/urls.py @@ -19,6 +19,9 @@ from django.urls import path from . import views urlpatterns = [ + path('tv/club///classement/', views.tv_ranking, name='ranks'), + path('club///classement/', views.ranking, name='ranks'), + path('match//', views.match, name='match'), path('tv/match//', views.match_tv, name='match'), diff --git a/scores/views.py b/scores/views.py index 3bb0859..0d6606a 100644 --- a/scores/views.py +++ b/scores/views.py @@ -186,6 +186,25 @@ def tv_teams_tournament(request, tournament_id): } return HttpResponse(template.render(context, request)) +def tv_ranking(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/ranks.html') + context = { + 'tournament': tournament, + 'tv': True, + } + return HttpResponse(template.render(context, request)) + +def ranking(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/ranks.html') + context = { + 'tournament': tournament, + } + return HttpResponse(template.render(context, request)) + class UserViewSet(viewsets.ModelViewSet): """ API endpoint that allows users to be viewed or edited.