diff --git a/scores/migrations/0025_remove_match_teams_match_teamone_match_teamtwo.py b/scores/migrations/0025_remove_match_teams_match_teamone_match_teamtwo.py new file mode 100644 index 0000000..ec8849b --- /dev/null +++ b/scores/migrations/0025_remove_match_teams_match_teamone_match_teamtwo.py @@ -0,0 +1,28 @@ +# Generated by Django 4.2 on 2023-08-11 17:54 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('scores', '0024_alter_match_teams'), + ] + + operations = [ + migrations.RemoveField( + model_name='match', + name='teams', + ), + migrations.AddField( + model_name='match', + name='teamOne', + field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='teamOne', to='scores.team'), + ), + migrations.AddField( + model_name='match', + name='teamTwo', + field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='teamTwo', to='scores.team'), + ), + ] diff --git a/scores/models.py b/scores/models.py index f72a7ba..dbde38a 100644 --- a/scores/models.py +++ b/scores/models.py @@ -89,8 +89,9 @@ class Match(models.Model): team2scorecolumn4 = models.CharField(max_length=200, blank=True) team2scorecolumn5 = models.CharField(max_length=200, blank=True) - teams = models.ManyToManyField(Team, blank=True) - + teamOne = models.ForeignKey(Team, related_name="teamOne", on_delete=models.SET_NULL, default=None, blank=True, null=True) + teamTwo = models.ForeignKey(Team, related_name="teamTwo", on_delete=models.SET_NULL, default=None, blank=True, null=True) + def poule(self): return self.court / 100 diff --git a/scores/serializers.py b/scores/serializers.py index 744f812..799e632 100644 --- a/scores/serializers.py +++ b/scores/serializers.py @@ -23,7 +23,7 @@ class MatchSerializer(serializers.HyperlinkedModelSerializer): model = Match fields = ['id', 'court', 'match_index', 'tournament', 'date', 'enddate', 'title', 'refreshrate', 'team1', 'team2', 'team3', 'team4', 'team5', 'hasWalkOutTeam', 'team1scorecolumn1', 'team1scorecolumn2', 'team1scorecolumn3', 'team1scorecolumn4', 'team1scorecolumn5', - 'team2scorecolumn1', 'team2scorecolumn2', 'team2scorecolumn3', 'team2scorecolumn4', 'team2scorecolumn5', 'teams'] + 'team2scorecolumn1', 'team2scorecolumn2', 'team2scorecolumn3', 'team2scorecolumn4', 'team2scorecolumn5', 'teamOne', 'teamTwo'] class TeamSerializer(serializers.HyperlinkedModelSerializer): class Meta: diff --git a/scores/templates/scores/match.html b/scores/templates/scores/match.html index 7762bc6..d316423 100644 --- a/scores/templates/scores/match.html +++ b/scores/templates/scores/match.html @@ -104,7 +104,7 @@ - {% if match.teams.all|length == 2 %} + {% if match.teamOne and match.teamTwo %}
@@ -115,23 +115,36 @@ - {% for team in match.teams.all %} - - - + + + + + + + + + + - {% endfor %}
Rang Entrée
- {% for player in team.players.all %} + {% for player in match.teamOne.players.all %}
{{ player.name }} {{ club_name }}
{% endfor %}
- {% for player in team.players.all %} + {% for player in match.teamOne.players.all %}
({{ player.rank }})
{% endfor %}
{{ team.rank }}#{{ team.position }}{{ team.position_label }}{{ match.teamOne.rank }}#{{ match.teamOne.position }}{{ match.teamOne.position_label }}
+ {% for player in match.teamTwo.players.all %} +
{{ player.name }} {{ club_name }}
+ {% endfor %} +
+ {% for player in match.teamTwo.players.all %} +
({{ player.rank }})
+ {% endfor %} +
{{ match.teamTwo.rank }}#{{ match.teamTwo.position }}{{ match.teamTwo.position_label }}