diff --git a/server/admin.py b/server/admin.py index b05e600c..6d024f91 100644 --- a/server/admin.py +++ b/server/admin.py @@ -16,9 +16,11 @@ from server.season.models import Season from server.series.models import Series, SeriesRegistration, SeriesRosterInvitation from server.tournament.models import ( + Bracket, Event, Match, Pool, + PositionPool, Registration, Tournament, TournamentField, @@ -137,6 +139,26 @@ def get_name(self, obj: Pool) -> str: return obj.tournament.event.title +@admin.register(Bracket) +class BracketAdmin(admin.ModelAdmin[Bracket]): + search_fields = ["tournament__event__title"] + list_display = ["get_name", "name"] + + @admin.display(description="Tournament Name", ordering="tournament__event__title") + def get_name(self, obj: Pool) -> str: + return obj.tournament.event.title + + +@admin.register(PositionPool) +class PositionPoolAdmin(admin.ModelAdmin[PositionPool]): + search_fields = ["tournament__event__title"] + list_display = ["get_name", "name"] + + @admin.display(description="Tournament Name", ordering="tournament__event__title") + def get_name(self, obj: Pool) -> str: + return obj.tournament.event.title + + @admin.register(Match) class MatchAdmin(admin.ModelAdmin[Match]): search_fields = ["tournament__event__title"] diff --git a/server/management/commands/add_to_event_roster.py b/server/management/commands/add_to_event_roster.py index 58ad11a0..e98b5ab1 100644 --- a/server/management/commands/add_to_event_roster.py +++ b/server/management/commands/add_to_event_roster.py @@ -7,7 +7,6 @@ from server.core.models import Player, Team, User from server.tournament.models import Event, Registration, Tournament -from server.series.utils import register_player from server.tournament.utils import can_register_player_to_series_event @@ -27,11 +26,13 @@ def handle(self, *args: Any, **options: Any) -> None: except (Event.DoesNotExist, Team.DoesNotExist, Tournament.DoesNotExist): self.stderr.write(self.style.ERROR("Event / Team / Tournament does not exist")) return - + if team not in tournament.teams.all(): - self.stderr.write(self.style.ERROR(f"{team.name} is not registered for ${event.title} !")) + self.stderr.write( + self.style.ERROR(f"{team.name} is not registered for ${event.title} !") + ) return - + csv_file = options["csv_file"] with open(csv_file) as file: @@ -39,14 +40,14 @@ def handle(self, *args: Any, **options: Any) -> None: for row in csv_reader: # Process each row of the CSV file email = row["email"].strip().lower() - + try: user = User.objects.get(username=email) player = Player.objects.get(user=user) except (User.DoesNotExist, Player.DoesNotExist): self.stderr.write(self.style.ERROR(f"Player not found: {email}")) continue - + if event.series: can_register, error = can_register_player_to_series_event( event=event, team=team, player=player @@ -63,5 +64,9 @@ def handle(self, *args: Any, **options: Any) -> None: try: registration.save() except IntegrityError: - self.stderr.write(self.style.ERROR(f"Error: Player already added to another team for this event, player: {email}")) - continue \ No newline at end of file + self.stderr.write( + self.style.ERROR( + f"Error: Player already added to another team for this event, player: {email}" + ) + ) + continue