[WIP] Update models

This commit is contained in:
Gregory Trullemans 2024-04-16 11:01:21 +02:00
parent 81727fbdf8
commit 46bc94bed1
3 changed files with 79 additions and 0 deletions

View File

@ -19,6 +19,7 @@ from .models import (
ChronoDetails,
GymnastHasRoutine,
SeasonInformation,
CompetitionCategory,
NumberOfRoutineDone,
CompetitivePointsStats,
)
@ -303,3 +304,22 @@ class CompetitivePointsStatsAdmin(admin.ModelAdmin):
("statistic_type", ChoiceDropdownFilter),
("routine_type", ChoiceDropdownFilter), # A supprimer ?
)
@admin.register(CompetitionCategory)
class CompetitionCategoryAdmin(admin.ModelAdmin):
model = CompetitionCategory
fields = (
"long_label",
"short_label",
"age_min",
"age_max",
"informations",
)
list_display = (
"long_label",
"short_label",
"age_min",
"age_max",
)

View File

@ -0,0 +1,44 @@
# Generated by Django 4.2 on 2024-04-16 08:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("followup", "0066_remove_seasoninformation_category"),
]
operations = [
migrations.CreateModel(
name="CompetitionCategory",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"informations",
models.TextField(
blank=True,
help_text="Only MarkDown is authorized",
null=True,
verbose_name="Comments",
),
),
("long_label", models.CharField(max_length=100)),
("short_label", models.CharField(max_length=10)),
("age_min", models.PositiveSmallIntegerField(blank=True, null=True)),
("age_max", models.PositiveSmallIntegerField(blank=True, null=True)),
],
options={
"verbose_name": "Competition Category",
"verbose_name_plural": "Competition Categories",
},
),
]

View File

@ -669,6 +669,21 @@ class Intensity(Markdownizable, Seasonisable):
return self.difficulty_asked / 10
class CompetitionCategory(Markdownizable):
"""Classe représentant les catégories de compétitions"""
class Meta:
verbose_name = "Competition Category"
verbose_name_plural = "Competition Categories"
long_label = models.CharField(max_length=100)
short_label = models.CharField(max_length=10)
age_min = models.PositiveSmallIntegerField(blank=True, null=True)
age_max = models.PositiveSmallIntegerField(blank=True, null=True)
def __str__(self):
return f"{self.long_label} ({self.short_label}) : {self.age_min} - {self.age_max}"
class SeasonInformation(models.Model):
"""Classe représentant l'intensité d'un entraînement"""