Rework Teams/Positions access control and add full Locations/Opponents CRUD
Team managers/coaches now only see their own teams, can't create teams, and can view (but not edit) positions -- admins keep full rights. Locations and Opponents move from read-only stubs to full CRUD, gated to admins and management-position staff, with a country dropdown (django-countries) instead of free text. Also: the team list shows player/staff counts, and deleting a news item's main photo promotes another one instead of leaving the item without one. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R1gj3J1QPfP38XWpnpbFpy
This commit is contained in:
23
events/migrations/0011_location_is_home_and_more.py
Normal file
23
events/migrations/0011_location_is_home_and_more.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 6.0.6 on 2026-08-04 09:37
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('club', '0017_club_season_duration_months_club_season_start'),
|
||||
('events', '0010_attendance_showed_up'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='location',
|
||||
name='is_home',
|
||||
field=models.BooleanField(default=False, help_text="The club's own ground, set from the control panel -- lets an event's location tell a home game from an away one.", verbose_name='home location'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='location',
|
||||
constraint=models.UniqueConstraint(condition=models.Q(('is_home', True)), fields=('club',), name='unique_home_location_per_club'),
|
||||
),
|
||||
]
|
||||
19
events/migrations/0012_alter_location_country.py
Normal file
19
events/migrations/0012_alter_location_country.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 6.0.6 on 2026-08-04 09:45
|
||||
|
||||
import django_countries.fields
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('events', '0011_location_is_home_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='location',
|
||||
name='country',
|
||||
field=django_countries.fields.CountryField(max_length=2, verbose_name='country'),
|
||||
),
|
||||
]
|
||||
@@ -1,5 +1,7 @@
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django_countries.fields import CountryField
|
||||
|
||||
from club.models import Season
|
||||
from members.models import Member
|
||||
@@ -25,12 +27,20 @@ class Location(ClubScopedModel):
|
||||
address = models.CharField(_("address"), max_length=255)
|
||||
city = models.CharField(_("city"), max_length=255)
|
||||
zip_code = models.CharField(_("zip code"), max_length=255)
|
||||
country = models.CharField(_("country"), max_length=255)
|
||||
country = CountryField(_("country"))
|
||||
is_home = models.BooleanField(
|
||||
_("home location"),
|
||||
default=False,
|
||||
help_text=_("The club's own ground, set from the control panel -- lets an event's location tell a home game from an away one."),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("location")
|
||||
verbose_name_plural = _("locations")
|
||||
ordering = ["name"]
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=["club"], condition=Q(is_home=True), name="unique_home_location_per_club"),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
Reference in New Issue
Block a user