diff --git a/tournaments/migrations/0094_playerregistration_captain.py b/tournaments/migrations/0094_playerregistration_captain.py new file mode 100644 index 0000000..17d54e1 --- /dev/null +++ b/tournaments/migrations/0094_playerregistration_captain.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.11 on 2024-11-15 07:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tournaments', '0093_drawlog_draw_type_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='playerregistration', + name='captain', + field=models.BooleanField(default=False), + ), + ] diff --git a/tournaments/models/player_enums.py b/tournaments/models/player_enums.py index 59c46a7..11ee89a 100644 --- a/tournaments/models/player_enums.py +++ b/tournaments/models/player_enums.py @@ -15,6 +15,7 @@ class PlayerPaymentType(models.IntegerChoices): class PlayerDataSource(models.IntegerChoices): FRENCH_FEDERATION = 0, 'French Federation' BEACH_PADEL = 1, 'Beach Padel' + ONLINE_REGISTRATION = 2, 'Online Registration' class PlayerSexType(models.IntegerChoices): FEMALE = 0, 'Female' diff --git a/tournaments/models/player_registration.py b/tournaments/models/player_registration.py index b35badb..7e9e6ec 100644 --- a/tournaments/models/player_registration.py +++ b/tournaments/models/player_registration.py @@ -33,6 +33,7 @@ class PlayerRegistration(models.Model): source = models.IntegerField(choices=PlayerDataSource.choices, null=True, blank=True) has_arrived = models.BooleanField(default=False) + captain = models.BooleanField(default=False) def __str__(self): return self.name() diff --git a/tournaments/models/team_registration.py b/tournaments/models/team_registration.py index 78da28b..e1112da 100644 --- a/tournaments/models/team_registration.py +++ b/tournaments/models/team_registration.py @@ -57,6 +57,11 @@ class TeamRegistration(models.Model): else: return [pr.shortened_name() for pr in players] + @property + def players(self): + # Fetch related PlayerRegistration objects + return self.playerregistration_set.all().order_by('rank') + def player_names(self): names = self.player_names_as_list() str = " - ".join(names) @@ -90,6 +95,10 @@ class TeamRegistration(models.Model): else: return "--" + def set_weight(self): + self.weight = self.playerregistration_set.aggregate(total_weight=models.Sum('rank'))['total_weight'] or 0 + self.save() # Save the updated weight if necessary + def is_valid_for_summon(self): return len(self.playerregistration_set.all()) > 0 diff --git a/tournaments/templates/register_tournament.html b/tournaments/templates/register_tournament.html index c1021cb..af45377 100644 --- a/tournaments/templates/register_tournament.html +++ b/tournaments/templates/register_tournament.html @@ -29,12 +29,22 @@
+

+

+ Informations de contact +
+

{{ team_form.as_p }}
{% if current_players %} -