From ddfd32ceb8d0e7c222225483a31db3332c29b7d3 Mon Sep 17 00:00:00 2001 From: scayac Date: Wed, 8 Oct 2025 22:21:16 +0200 Subject: [PATCH] =?UTF-8?q?Gestion=20courses=20multi=20tours=20Nettoyage?= =?UTF-8?q?=20views.py=20Am=C3=A9lioration=20affichage=20page=20principale?= =?UTF-8?q?=20Update=20.gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- ...e_unique_together_arrivee_tour_and_more.py | 26 ++ main/models.py | 6 +- main/templates/course_detail.html | 70 +++- main/templates/main.html | 26 +- main/templates/scan_result.html | 9 +- main/views.py | 325 +++++++++++------- 7 files changed, 315 insertions(+), 149 deletions(-) create mode 100644 main/migrations/0002_alter_arrivee_unique_together_arrivee_tour_and_more.py diff --git a/.gitignore b/.gitignore index a105451..93789e4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,6 @@ staticfiles/* __pycache__ __init__.py -db.sqlite3 +*.sqlite3 *.crt *.key \ No newline at end of file diff --git a/main/migrations/0002_alter_arrivee_unique_together_arrivee_tour_and_more.py b/main/migrations/0002_alter_arrivee_unique_together_arrivee_tour_and_more.py new file mode 100644 index 0000000..eca1f4f --- /dev/null +++ b/main/migrations/0002_alter_arrivee_unique_together_arrivee_tour_and_more.py @@ -0,0 +1,26 @@ +# Generated by Django 5.2.7 on 2025-10-08 18:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0001_initial'), + ] + + operations = [ + migrations.AlterUniqueTogether( + name='arrivee', + unique_together=set(), + ), + migrations.AddField( + model_name='arrivee', + name='tour', + field=models.PositiveIntegerField(default=1), + ), + migrations.AlterUniqueTogether( + name='arrivee', + unique_together={('course', 'coureur', 'tour')}, + ), + ] diff --git a/main/models.py b/main/models.py index 490f360..73482b6 100644 --- a/main/models.py +++ b/main/models.py @@ -43,10 +43,14 @@ class Arrivee(models.Model): coureur = models.ForeignKey('Coureur', on_delete=models.CASCADE) temps = models.DurationField() rang = models.PositiveIntegerField() + # numéro de tour (pour les courses de type multi) + tour = models.PositiveIntegerField(default=1) date_arrivee = models.DateTimeField(auto_now_add=True) class Meta: - unique_together = ('course', 'coureur') + # Allow multiple arrivals for the same coureur in the same course + # by including the tour in the uniqueness constraint + unique_together = ('course', 'coureur', 'tour') ordering = ['rang'] def __str__(self): diff --git a/main/templates/course_detail.html b/main/templates/course_detail.html index e79c313..db10fd8 100644 --- a/main/templates/course_detail.html +++ b/main/templates/course_detail.html @@ -53,6 +53,9 @@
Arrivées
+ {% if course.type == 'multi' %} + + {% endif %}
{% csrf_token %} @@ -74,7 +77,7 @@ - + @@ -84,7 +87,7 @@ {% for a in arrivees %} - + @@ -115,7 +118,11 @@
Rang{% if course.type == 'multi' %}Tour{% else %}Rang{% endif %} Nom Prénom Classe
{{ a.rang }}{% if course.type == 'multi' %}{{ a.tour }}{% else %}{{ a.rang }}{% endif %} {{ a.coureur.nom }} {{ a.coureur.prenom }} {{ a.coureur.classe }}