From 70a5f994cd779bb850b500fdddeb1952452559e6 Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 23 Apr 2024 16:24:20 +0200 Subject: [PATCH] Minor visual fixes --- tournaments/admin.py | 2 +- .../migrations/0029_purchase_quantity.py | 18 ++++++++++++++++++ tournaments/models/group_stage.py | 2 +- tournaments/models/purchase.py | 1 + tournaments/models/tournament.py | 4 +++- .../templates/tournaments/group_stages.html | 2 +- tournaments/templates/tournaments/summons.html | 2 +- 7 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 tournaments/migrations/0029_purchase_quantity.py diff --git a/tournaments/admin.py b/tournaments/admin.py index d3cab6a..32999f5 100644 --- a/tournaments/admin.py +++ b/tournaments/admin.py @@ -51,7 +51,7 @@ class ClubAdmin(admin.ModelAdmin): list_display = ['name', 'acronym', 'phone'] class PurchaseAdmin(admin.ModelAdmin): - list_display = ['user', 'identifier', 'purchase_date', 'product_id'] + list_display = ['user', 'identifier', 'purchase_date', 'product_id', 'quantity'] admin.site.register(CustomUser, CustomUserAdmin) admin.site.register(Club, ClubAdmin) diff --git a/tournaments/migrations/0029_purchase_quantity.py b/tournaments/migrations/0029_purchase_quantity.py new file mode 100644 index 0000000..d0e4ce4 --- /dev/null +++ b/tournaments/migrations/0029_purchase_quantity.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.11 on 2024-04-23 13:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tournaments', '0028_rename_productid_purchase_product_id_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='purchase', + name='quantity', + field=models.IntegerField(blank=True, null=True), + ), + ] diff --git a/tournaments/models/group_stage.py b/tournaments/models/group_stage.py index b9efcaf..1b9af33 100644 --- a/tournaments/models/group_stage.py +++ b/tournaments/models/group_stage.py @@ -12,7 +12,7 @@ class GroupStage(models.Model): format = models.IntegerField(default=FederalMatchCategory.NINE_GAMES, choices=FederalMatchCategory.choices, null=True, blank=True) def __str__(self): - return f"{self.tournament.name} - {self.name()}" + return f"{self.tournament.display_name()} - {self.name()}" def name(self): return f"Poule {self.index}" diff --git a/tournaments/models/purchase.py b/tournaments/models/purchase.py index 51736d8..6dd45dd 100644 --- a/tournaments/models/purchase.py +++ b/tournaments/models/purchase.py @@ -8,6 +8,7 @@ class Purchase(models.Model): identifier = models.IntegerField() purchase_date = models.DateTimeField() product_id = models.CharField(max_length=100) + quantity = models.IntegerField(null=True, blank=True) def __str__(self): return f"{self.identifier} > {self.product_id} - {self.purchase_date} - {self.user.username}" diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 3ca6a80..0dbf9cb 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -135,7 +135,9 @@ class Tournament(models.Model): return MatchGroup(name, live_matches) def live_group_stages(self): - return [gs.live_group_stages() for gs in self.groupstage_set.all()] + group_stages = list(self.groupstage_set.all()) + group_stages.sort(key=lambda gs: gs.index) + return [gs.live_group_stages() for gs in group_stages] def broadcast_content(self): diff --git a/tournaments/templates/tournaments/group_stages.html b/tournaments/templates/tournaments/group_stages.html index c931b47..66c25da 100644 --- a/tournaments/templates/tournaments/group_stages.html +++ b/tournaments/templates/tournaments/group_stages.html @@ -2,7 +2,7 @@ {% block head_title %}Poules{% endblock %} {% block first_title %}{{ tournament.event.display_name }}{% endblock %} -{% block second_title %}{{ tournament.name }}{% endblock %} +{% block second_title %}{{ tournament.display_name }}{% endblock %} {% block content %} diff --git a/tournaments/templates/tournaments/summons.html b/tournaments/templates/tournaments/summons.html index 8a79d62..aeab95c 100644 --- a/tournaments/templates/tournaments/summons.html +++ b/tournaments/templates/tournaments/summons.html @@ -1,7 +1,7 @@ {% extends 'tournaments/base.html' %} {% block head_title %}Convocations{% endblock %} -{% block first_title %}{{ tournament.name }}{% endblock %} +{% block first_title %}{{ tournament.display_name }}{% endblock %} {% block second_title %}Convocations{% endblock %} {% block content %}