From 88ca6f4bc46b09ed9eb5dd85be0b76bfc2f08d80 Mon Sep 17 00:00:00 2001 From: Laurent Date: Sun, 10 Mar 2024 14:16:10 +0100 Subject: [PATCH] rename TeamCall into TeamSummon --- tournaments/models/__init__.py | 2 +- tournaments/models/tournament.py | 12 ++++++------ tournaments/serializers.py | 3 +-- tournaments/templates/tournaments/summon_row.html | 8 ++++---- tournaments/templates/tournaments/summons.html | 2 +- tournaments/urls.py | 2 +- tournaments/views.py | 8 ++++---- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/tournaments/models/__init__.py b/tournaments/models/__init__.py index 43669e7..c8ae85d 100644 --- a/tournaments/models/__init__.py +++ b/tournaments/models/__init__.py @@ -2,7 +2,7 @@ from .club import Club from .custom_user import CustomUser from .enums import FederalCategory, FederalLevelCategory, FederalAgeCategory, FederalMatchCategory from .event import Event -from .tournament import Tournament, TeamCall +from .tournament import Tournament, TeamSummon from .group_stage import GroupStage from .round import Round from .match import Match, LiveMatch diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 1a8e4ff..a707003 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -47,19 +47,19 @@ class Tournament(models.Model): def formatted_start_date(self): return self.start_date.strftime("%d/%m/%y") - def team_calls(self): + def team_summons(self): - team_calls = [] + summons = [] for team_registration in self.teamregistration_set.all(): call_date = team_registration.call_date if call_date: names = team_registration.team_names() stage = team_registration.next_stage() weight = team_registration.weight() - team_call = TeamCall(names, call_date, weight, stage, team_registration.logo) - team_calls.append(team_call) + summon = TeamSummon(names, call_date, weight, stage, team_registration.logo) + summons.append(summon) - return team_calls + return summons def live_matches(self): matches = [] @@ -81,7 +81,7 @@ class Tournament(models.Model): # # Convert dictionary to JSON # return json.dumps(dict) -class TeamCall: +class TeamSummon: def __init__(self, names, date, weight, stage, image): self.names = [] self.names = names diff --git a/tournaments/serializers.py b/tournaments/serializers.py index 42fe08f..f845c73 100644 --- a/tournaments/serializers.py +++ b/tournaments/serializers.py @@ -41,8 +41,7 @@ class EventSerializer(serializers.ModelSerializer): class Meta: # club_id = serializers.PrimaryKeyRelatedField(queryset=Club.objects.all()) model = Event - fields = ['id', 'club_id', 'date', 'name', 'federal_tournament_data', 'court_count', 'tenup_id', - 'group_stage_format', 'round_format', 'loser_round_format'] + fields = '__all__' class RoundSerializer(serializers.ModelSerializer): class Meta: diff --git a/tournaments/templates/tournaments/summon_row.html b/tournaments/templates/tournaments/summon_row.html index 59fa842..41805e5 100644 --- a/tournaments/templates/tournaments/summon_row.html +++ b/tournaments/templates/tournaments/summon_row.html @@ -6,12 +6,12 @@
- {% for name in team_call.names %} + {% for name in summon.names %}
{{ name }}
{% endfor %}
-
{{ team_call.weight }}
-
{{ team_call.date|date:'H:i' }}
-
{{ team_call.stage }}
+
{{ summon.weight }}
+
{{ summon.date|date:'H:i' }}
+
{{ summon.stage }}
diff --git a/tournaments/templates/tournaments/summons.html b/tournaments/templates/tournaments/summons.html index aa09d57..0116e48 100644 --- a/tournaments/templates/tournaments/summons.html +++ b/tournaments/templates/tournaments/summons.html @@ -43,7 +43,7 @@
- {% for team_call in team_calls %} + {% for summon in team_summons %} {% include 'tournaments/summon_row.html' %} diff --git a/tournaments/urls.py b/tournaments/urls.py index d811e23..55127b6 100644 --- a/tournaments/urls.py +++ b/tournaments/urls.py @@ -5,6 +5,6 @@ from . import views urlpatterns = [ path("", views.index, name="index"), path('tournament//', views.tournament, name='tournament'), - path('tournament//planning/', views.tournament_planning, name='tournament-planning'), + path('tournament//summons/', views.tournament_summons, name='tournament-summons'), path('tournament//json/', views.tournament_json, name='tournament-json'), ] diff --git a/tournaments/views.py b/tournaments/views.py index 4f0afa6..cdeb226 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -2,7 +2,7 @@ from django.shortcuts import render, get_object_or_404 from django.http import HttpResponse from .serializers import ClubSerializer, TournamentSerializer, UserSerializer, ChangePasswordSerializer, EventSerializer, RoundSerializer, GroupStageSerializer, MatchSerializer, TeamScoreSerializer, TeamRegistrationSerializer, PlayerRegistrationSerializer, LiveMatchSerializer from .models import Club, Tournament, CustomUser, Event, Round, GroupStage, Match, TeamScore, TeamRegistration, PlayerRegistration -from .models import TeamCall +from .models import TeamSummon from rest_framework import viewsets, permissions from rest_framework.authtoken.models import Token @@ -65,14 +65,14 @@ def tournament(request, tournament_id): # } # return HttpResponse(template.render(context, request)) -def tournament_planning(request, tournament_id): +def tournament_summons(request, tournament_id): tournament = get_object_or_404(Tournament, pk=tournament_id) - team_calls = tournament.team_calls() + team_summons = tournament.team_summons() template = loader.get_template('tournaments/summons.html') context = { - 'team_calls': team_calls, + 'team_summons': team_summons, } return HttpResponse(template.render(context, request))