diff --git a/tournaments/admin.py b/tournaments/admin.py index b69e2cb..c4284ac 100644 --- a/tournaments/admin.py +++ b/tournaments/admin.py @@ -5,36 +5,58 @@ from django.contrib.auth.forms import UserCreationForm, UserChangeForm from .forms import CustomUserCreationForm, CustomUserChangeForm - class CustomUserAdmin(UserAdmin): form = CustomUserChangeForm add_form = CustomUserCreationForm model = CustomUser - list_display = ['email', 'username', 'umpire_code'] + list_display = ['email', 'username', 'is_active'] fieldsets = [ - (None, {'fields': ['username', 'email', 'password', 'umpire_code', 'clubs', 'phone', 'first_name', 'last_name', 'licence_id', ]}), + (None, {'fields': ['username', 'email', 'password', 'umpire_code', 'clubs', 'phone', 'first_name', 'last_name', 'licence_id', 'country', ]}), ] add_fieldsets = [ ( None, { "classes": ["wide"], - "fields": ['username', 'email', 'password1', 'password2', 'umpire_code', 'clubs', 'phone', 'first_name', 'last_name', 'licence_id', ], + "fields": ['username', 'email', 'password1', 'password2', 'umpire_code', 'clubs', 'phone', 'first_name', 'last_name', 'licence_id', 'country', ], }, ), ] -class CustomTeamRegistration(admin.ModelAdmin): - model = TeamRegistration - list_display = ['player_names', 'name'] +class TeamRegistrationAdmin(admin.ModelAdmin): + list_display = ['player_names', 'name', 'tournament'] + +class TournamentAdmin(admin.ModelAdmin): + list_display = ['name', 'event', 'is_private', 'start_date'] + +class TeamScoreAdmin(admin.ModelAdmin): + list_display = ['match', 'team_registration', 'score'] + +class RoundAdmin(admin.ModelAdmin): + list_display = ['tournament', 'name', 'index', 'parent'] + +class PlayerRegistrationAdmin(admin.ModelAdmin): + list_display = ['first_name', 'last_name', 'licence_id', 'rank'] + +class MatchAdmin(admin.ModelAdmin): + list_display = ['__str__', 'round', 'group_stage', 'start_date', 'index'] + +class GroupStageAdmin(admin.ModelAdmin): + list_display = ['tournament', 'index'] + +class EventAdmin(admin.ModelAdmin): + list_display = ['name', 'club', 'creation_date', 'creator'] + +class ClubAdmin(admin.ModelAdmin): + list_display = ['name', 'acronym', 'phone'] admin.site.register(CustomUser, CustomUserAdmin) -admin.site.register(Club) -admin.site.register(Event) -admin.site.register(Round) -admin.site.register(GroupStage) -admin.site.register(Match) -admin.site.register(TeamScore) -admin.site.register(TeamRegistration, CustomTeamRegistration) -admin.site.register(Tournament) -admin.site.register(PlayerRegistration) +admin.site.register(Club, ClubAdmin) +admin.site.register(Event, EventAdmin) +admin.site.register(Round, RoundAdmin) +admin.site.register(GroupStage, GroupStageAdmin) +admin.site.register(Match, MatchAdmin) +admin.site.register(TeamScore, TeamScoreAdmin) +admin.site.register(TeamRegistration, TeamRegistrationAdmin) +admin.site.register(Tournament, TournamentAdmin) +admin.site.register(PlayerRegistration, PlayerRegistrationAdmin) diff --git a/tournaments/forms.py b/tournaments/forms.py index 4ca0f06..722330d 100644 --- a/tournaments/forms.py +++ b/tournaments/forms.py @@ -5,10 +5,10 @@ class CustomUserCreationForm(UserCreationForm): class Meta: model = CustomUser - fields = UserCreationForm.Meta.fields + ('umpire_code', 'clubs', 'phone', 'first_name', 'last_name', 'licence_id', ) + fields = UserCreationForm.Meta.fields + ('umpire_code', 'clubs', 'phone', 'first_name', 'last_name', 'licence_id', 'country') class CustomUserChangeForm(UserChangeForm): class Meta: model = CustomUser - fields = UserCreationForm.Meta.fields + ('umpire_code', 'clubs', 'phone', 'first_name', 'last_name', 'licence_id',) + fields = UserCreationForm.Meta.fields + ('umpire_code', 'clubs', 'phone', 'first_name', 'last_name', 'licence_id', 'country') diff --git a/tournaments/migrations/0025_customuser_country.py b/tournaments/migrations/0025_customuser_country.py new file mode 100644 index 0000000..c4094b8 --- /dev/null +++ b/tournaments/migrations/0025_customuser_country.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.11 on 2024-04-04 08:16 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tournaments', '0024_rename_loser_round_parent'), + ] + + operations = [ + migrations.AddField( + model_name='customuser', + name='country', + field=models.CharField(blank=True, max_length=40, null=True), + ), + ] diff --git a/tournaments/models/custom_user.py b/tournaments/models/custom_user.py index 1f6f71b..c395087 100644 --- a/tournaments/models/custom_user.py +++ b/tournaments/models/custom_user.py @@ -12,10 +12,7 @@ class CustomUser(AbstractUser): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) licence_id = models.CharField(max_length=10, null=True, blank=True) + country = models.CharField(max_length=40, null=True, blank=True) def __str__(self): return self.username - - # quels sont les champs qu'on veut absolument lorsque l'on créé un user ? - # first/last name ? - # club ? diff --git a/tournaments/models/match.py b/tournaments/models/match.py index d477b50..1863e69 100644 --- a/tournaments/models/match.py +++ b/tournaments/models/match.py @@ -20,16 +20,15 @@ class Match(models.Model): broadcasted = models.BooleanField(default=False) def __str__(self): - match_name = self.name if self.name else self.backup_name() #"x is greater" if x > y else "y is greater" - items = [match_name, self.formatted_start_date()] - desc = " - ".join(items) - player_names = " / ".join(self.player_names()) - if self.round: - return f"{desc} > {player_names}" - elif self.group_stage: - return f"{desc} > {player_names}" - else: - return "--" + return " / ".join(self.player_names()) + + # player_names = " / ".join(self.player_names()) + # if self.round: + # return f"{match_name} > {player_names}" + # elif self.group_stage: + # return f"{match_name} > {player_names}" + # else: + # return "--" def backup_name(self): items = []