Remove RefereeLevel.ordering now inherits_from covers the same need
A separate manually-kept number for "which tier is higher" is redundant now that the inheritance chain already expresses it, and risked drifting out of sync with it. Levels list/sort by name only. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ECGMEwrc2k4D8VQuwjstj9
This commit is contained in:
@@ -72,11 +72,11 @@ class StaffAssignmentAdmin(admin.ModelAdmin):
|
||||
|
||||
@admin.register(RefereeLevel)
|
||||
class RefereeLevelAdmin(admin.ModelAdmin):
|
||||
list_display = ["name", "club", "ordering", "inherits_from", "team_list"]
|
||||
list_display = ["name", "club", "inherits_from", "team_list"]
|
||||
list_filter = ["club"]
|
||||
search_fields = ["name"]
|
||||
autocomplete_fields = ["teams", "inherits_from"]
|
||||
ordering = ["club", "ordering", "name"]
|
||||
ordering = ["club", "name"]
|
||||
|
||||
@admin.display(description=_("teams"))
|
||||
def team_list(self, obj):
|
||||
|
||||
21
teams/migrations/0012_alter_refereelevel_options_and_more.py
Normal file
21
teams/migrations/0012_alter_refereelevel_options_and_more.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# Generated by Django 6.0.6 on 2026-08-20 21:02
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('teams', '0011_refereelevel_inherits_from'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='refereelevel',
|
||||
options={'ordering': ['name'], 'verbose_name': 'referee level', 'verbose_name_plural': 'referee levels'},
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='refereelevel',
|
||||
name='ordering',
|
||||
),
|
||||
]
|
||||
@@ -121,22 +121,23 @@ class TeamMembership(UUIDModel):
|
||||
|
||||
class RefereeLevel(ClubScopedModel):
|
||||
"""A club-defined referee qualification tier (e.g. "Regional", "National")
|
||||
-- admin-managed, like Position, so a club can name and reorder its own
|
||||
levels rather than picking from a fixed list. Owns which teams it
|
||||
qualifies a referee for: eligibility is a property of the *level*, not of
|
||||
the individual referee -- a club typically has a handful of levels, each
|
||||
unlocking a tier of teams/competitions, rather than hand-picking teams per
|
||||
referee.
|
||||
-- admin-managed, like Position, so a club can name its own levels rather
|
||||
than picking from a fixed list. Owns which teams it qualifies a referee
|
||||
for: eligibility is a property of the *level*, not of the individual
|
||||
referee -- a club typically has a handful of levels, each unlocking a
|
||||
tier of teams/competitions, rather than hand-picking teams per referee.
|
||||
|
||||
`inherits_from` chains levels together so a higher tier doesn't need every
|
||||
lower tier's team re-added by hand: a "National" referee is automatically
|
||||
eligible for everything "Regional" (its inherits_from) covers, and so on
|
||||
down the chain -- see eligible_team_ids, the single definition every
|
||||
consumer (RefereeProfile.eligible_teams, events.services.referees) reads
|
||||
through."""
|
||||
through. That chain is also what expresses which tier is "higher" now --
|
||||
there used to be a manual `ordering` field for this too, dropped once
|
||||
inherits_from covered the same need without a second, independently-kept
|
||||
number to keep in sync with it."""
|
||||
|
||||
name = models.CharField(_("name"), max_length=255)
|
||||
ordering = models.PositiveSmallIntegerField(_("ordering"), default=0, help_text=_("Lower numbers are listed first. Levels with the same number are ordered by name."))
|
||||
teams = models.ManyToManyField(Team, related_name="referee_levels", blank=True, verbose_name=_("qualifies for"), help_text=_("Members holding this level can be assigned to referee these teams' home games."))
|
||||
inherits_from = models.ForeignKey(
|
||||
"self",
|
||||
@@ -151,7 +152,7 @@ class RefereeLevel(ClubScopedModel):
|
||||
class Meta:
|
||||
verbose_name = _("referee level")
|
||||
verbose_name_plural = _("referee levels")
|
||||
ordering = ["ordering", "name"]
|
||||
ordering = ["name"]
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=["club", "name"], name="unique_referee_level_name_per_club"),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user