From 0e1ba62df542134b9e87e7dcc0da183b77e0e408 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Fri, 28 Jul 2023 19:10:46 +0200 Subject: [PATCH] fix issue with background_color --- ...undcolor_team_background_color_and_more.py | 28 +++++++++++++++++++ scores/models.py | 6 ++-- scores/serializers.py | 2 +- scores/views.py | 2 +- 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 scores/migrations/0018_rename_backgroundcolor_team_background_color_and_more.py diff --git a/scores/migrations/0018_rename_backgroundcolor_team_background_color_and_more.py b/scores/migrations/0018_rename_backgroundcolor_team_background_color_and_more.py new file mode 100644 index 0000000..dd19644 --- /dev/null +++ b/scores/migrations/0018_rename_backgroundcolor_team_background_color_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 4.2 on 2023-07-28 17:04 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('scores', '0017_match_refreshrate_tournament_tournament_index'), + ] + + operations = [ + migrations.RenameField( + model_name='team', + old_name='backgroundColor', + new_name='background_color', + ), + migrations.RenameField( + model_name='team', + old_name='dateLabel', + new_name='date_label', + ), + migrations.RenameField( + model_name='team', + old_name='positionLabel', + new_name='position_label', + ), + ] diff --git a/scores/models.py b/scores/models.py index 8836a42..d402f2f 100644 --- a/scores/models.py +++ b/scores/models.py @@ -115,8 +115,8 @@ class Team(models.Model): rank = models.IntegerField(default=0) position = models.IntegerField(default=0) bracket = models.BooleanField(default=False) - positionLabel = models.CharField(max_length=200, blank=True) - dateLabel = models.CharField(max_length=200, blank=True) - backgroundColor = models.CharField(max_length=200, blank=True) + 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) diff --git a/scores/serializers.py b/scores/serializers.py index 7295715..ef0f229 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', 'brackgroundColor', 'rank', 'position', 'bracket', 'positionLabel', 'dateLabel', 'match'] + fields = ['id', 'name', 'background_color', 'rank', 'position', 'bracket', 'position_label', 'date_label', 'match'] diff --git a/scores/views.py b/scores/views.py index c2d0c74..17c2e5d 100644 --- a/scores/views.py +++ b/scores/views.py @@ -200,7 +200,7 @@ class MatchViewSet(viewsets.ModelViewSet): """ API endpoint that allows matches to be viewed or edited. """ - queryset = Match.objects.all().order_by('match_index') + queryset = Match.objects.all().order_by('court') serializer_class = MatchSerializer permission_classes = [permissions.IsAuthenticated]