diff --git a/scores/migrations/0019_remove_team_match_team_tournament.py b/scores/migrations/0019_remove_team_match_team_tournament.py
new file mode 100644
index 0000000..afb85dc
--- /dev/null
+++ b/scores/migrations/0019_remove_team_match_team_tournament.py
@@ -0,0 +1,23 @@
+# Generated by Django 4.2 on 2023-07-28 18:32
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('scores', '0018_rename_backgroundcolor_team_background_color_and_more'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='team',
+ name='match',
+ ),
+ migrations.AddField(
+ model_name='team',
+ name='tournament',
+ field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='scores.tournament'),
+ ),
+ ]
diff --git a/scores/models.py b/scores/models.py
index d402f2f..6d80ed8 100644
--- a/scores/models.py
+++ b/scores/models.py
@@ -24,6 +24,9 @@ class Tournament(models.Model):
def ended_matches(self):
return self.matches.filter(enddate__isnull=False).order_by('court')
+
+ def teams(self):
+ return self.team_set.order_by('position')
class Match(models.Model):
tournament = models.ForeignKey(Tournament, on_delete=models.CASCADE, default=None)
@@ -51,9 +54,6 @@ class Match(models.Model):
team2scorecolumn4 = models.CharField(max_length=200, blank=True)
team2scorecolumn5 = models.CharField(max_length=200, blank=True)
- def teams(self):
- return self.team_set.order_by('position')
-
def poule(self):
return self.court / 100
@@ -118,5 +118,5 @@ class Team(models.Model):
position_label = models.CharField(max_length=200, blank=True)
date_label = models.CharField(max_length=200, blank=True)
background_color = models.CharField(max_length=200, blank=True)
- match = models.ForeignKey(Match, on_delete=models.CASCADE, default=None)
+ tournament = models.ForeignKey(Tournament, on_delete=models.CASCADE, default=None, blank=True, null=True)
diff --git a/scores/serializers.py b/scores/serializers.py
index 2ec9259..f4c803c 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', 'match']
+ fields = ['id', 'name', 'background_color', 'rank', 'position', 'bracket', 'position_label', 'date_label', 'tournament']
diff --git a/scores/templates/scores/match.html b/scores/templates/scores/match.html
index 86aef7d..e443993 100644
--- a/scores/templates/scores/match.html
+++ b/scores/templates/scores/match.html
@@ -3,21 +3,9 @@
{% load static %}
- {% if tv %}
-
-
-
- {% endif %}
-
Padel
- {% if match.teams %}
-
- {% else %}
- {% endif %}
{% if tv %}
@@ -25,38 +13,6 @@
{% endif %}
- {% if tv %}
-
- {% endif %}
-
{% if match.tournament.club.header %}
{{ match.tournament.club.header }}
{% endif %}
@@ -66,39 +22,7 @@
{{ match.tournament.name }}
-
- {% if match.teams %}
-
Liste des équipes
-
-
- | Rang |
- Nom |
- Poids |
- Entrée |
- Jour |
-
- {% for team in teams %}
-
- | #{{ team.position }} |
- {{ team.name|linebreaksbr }} |
- {{ team.rank }} |
-
- {% if team.bracket %}
- Poule |
- {% else %}
- {{ team.positionLabel }} |
- {% endif %}
-
- {% if team.dateLabel %}
- {{ team.dateLabel }} |
- {% else %}
- - |
- {% endif %}
-
- {% endfor %}
-
-
- {% else %}
+
{{ match.title }}
{% if match.team3 %}
@@ -159,11 +83,6 @@
{% endif %}
-
-
- {% endif %}
-
-
diff --git a/scores/templates/scores/teams.html b/scores/templates/scores/teams.html
new file mode 100644
index 0000000..9a20e83
--- /dev/null
+++ b/scores/templates/scores/teams.html
@@ -0,0 +1,110 @@
+
+
+{% load static %}
+
+
+ {% if tv %}
+
+
+
+ {% endif %}
+
+
+
Padel
+
+
+{% if tv %}
+
+{% else %}
+
+{% endif %}
+
+ {% if tv %}
+
+ {% endif %}
+
+ {% if tournament.club.header %}
+
{{ tournament.club.header }}
+ {% endif %}
+
+
+ {% autoescape off %}
+ {{ tournament.name }}
+
+
+
+ {% if tournament.teams %}
+
Liste des équipes
+
+
+ | Rang |
+ Nom |
+ Poids |
+ Entrée |
+ Jour |
+
+ {% for team in tournament.teams %}
+
+ | #{{ team.position }} |
+ {{ team.name|linebreaksbr }} |
+ {{ team.rank }} |
+
+ {% if team.bracket %}
+ Poule |
+ {% else %}
+ {{ team.positionLabel }} |
+ {% endif %}
+
+ {% if team.dateLabel %}
+ {{ team.dateLabel }} |
+ {% else %}
+ - |
+ {% endif %}
+
+ {% endfor %}
+
+ {% endif %}
+
+
+
+
+ {% endautoescape %}
+
+
+ {% if tournament.club.footer %}
+
+ {% endif %}
+
+
+
+
diff --git a/scores/urls.py b/scores/urls.py
index ccd8e54..f9bbc5d 100644
--- a/scores/urls.py
+++ b/scores/urls.py
@@ -21,21 +21,21 @@ from . import views
urlpatterns = [
path('match/
/', views.match, name='match'),
- path('tv/club///equipes/', views.tv_teams_club_name_tournament, name='match_scrolling'),
- path('tv/tournoi//equipes/', views.tv_teams_tournament_name, name='match_scrolling'),
- path('tv/club///equipes/', views.tv_teams_club_name_tournament_name, name='match_scrolling'),
+ path('tv/club///equipes/', views.tv_teams_club_name_tournament, name='teams'),
+ path('tv/tournoi//equipes/', views.tv_teams_tournament_name, name='teams'),
+ path('tv/club///equipes/', views.tv_teams_club_name_tournament_name, name='teams'),
- path('tv/', views.index, name='index_scrolling'),
- path('tv/tournoi//', views.tv_tournament_name, name='tournament_scrolling'),
+ path('tv/', views.index, name='index'),
+ path('tv/tournoi//', views.tv_tournament_name, name='tournament'),
path('tv/club//', views.club_name, name='club'),
- path('tv/club///', views.tv_club_name_tournament, name='tournament_scrolling'),
- path('tv/club///', views.tv_club_name_tournament_name, name='tournament_scrolling'),
+ path('tv/club///', views.tv_club_name_tournament, name='tournament'),
+ path('tv/club///', views.tv_club_name_tournament_name, name='tournament'),
- path('club///equipes/', views.teams_club_name_tournament_name, name='match'),
- path('tournoi//equipes/', views.teams_tournament_name, name='match'),
- path('tournoi//equipes/', views.teams_tournament, name='match'),
- path('club///equipes/', views.teams_club_name_tournament_name, name='match'),
- path('club///equipes', views.teams_club_name_tournament, name='match'),
+ path('club///equipes/', views.teams_club_name_tournament_name, name='teams'),
+ path('tournoi//equipes/', views.teams_tournament_name, name='teams'),
+ path('tournoi//equipes/', views.teams_tournament, name='teams'),
+ path('club///equipes/', views.teams_club_name_tournament_name, name='teams'),
+ path('club///equipes', views.teams_club_name_tournament, name='teams'),
path('club///', views.club_name_tournament_name, name='tournament'),
path('club///', views.club_name_tournament, name='tournament'),
path('club//', views.club_name, name='club'),
diff --git a/scores/views.py b/scores/views.py
index 17c2e5d..687c861 100644
--- a/scores/views.py
+++ b/scores/views.py
@@ -70,11 +70,9 @@ def tournament(request, tournament_id):
def match(request, match_id):
match = get_object_or_404(Match, pk=match_id)
- teams = Team.objects.filter(match=match.id).order_by('position')
template = loader.get_template('scores/match.html')
context = {
'match': match,
- 'teams': teams,
}
return HttpResponse(template.render(context, request))
@@ -96,12 +94,9 @@ def teams_club_name_tournament_name(request, club_name, tournament_shortname):
def teams_tournament(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)
- match = Match.objects.filter(tournament=tournament.id).filter(match_index=-1).first()
- teams = Team.objects.filter(match=match.id).order_by('position')
- template = loader.get_template('scores/match.html')
+ template = loader.get_template('scores/teams.html')
context = {
- 'match': match,
- 'teams': teams,
+ 'tournament': tournament,
}
return HttpResponse(template.render(context, request))
@@ -162,12 +157,9 @@ def tv_teams_club_name_tournament_name(request, club_name, tournament_shortname)
def tv_teams_tournament(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id)
- match = Match.objects.filter(tournament=tournament.id).filter(match_index=-1).first()
- teams = Team.objects.filter(match=match.id).order_by('position')
- template = loader.get_template('scores/match.html')
+ template = loader.get_template('scores/teams.html')
context = {
- 'match': match,
- 'teams': teams,
+ 'tournament': tournament,
'tv': True,
}
return HttpResponse(template.render(context, request))