diff --git a/controlpanel/forms.py b/controlpanel/forms.py index 7458513..1cd850a 100644 --- a/controlpanel/forms.py +++ b/controlpanel/forms.py @@ -6,6 +6,7 @@ from waffle import get_waffle_flag_model from billing.models import DuePayment, Subscription, Tier, TierPrice from club.models import Club +from events.models import Location from .services.admins import find_member_by_email @@ -30,6 +31,21 @@ class ClubForm(forms.ModelForm): self.fields["slug"].required = False +class HomeLocationForm(forms.ModelForm): + """Create or update the club's home ground -- this *is* an events.Location row + (flagged ``is_home``), the same one that shows up under the club's own + Teams > Locations page, so the two stay in sync by construction rather than + needing anything to keep them that way.""" + + class Meta: + model = Location + fields = ["name", "address", "city", "zip_code", "country"] + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields["country"].widget.attrs.update({"data-searchable": "true", "data-search-placeholder": _("Type a country to search...")}) + + class ClubAdminForm(forms.Form): """Grant club-admin rights to an email address, creating the person if new.""" diff --git a/controlpanel/templates/controlpanel/_club_home_location_card.html b/controlpanel/templates/controlpanel/_club_home_location_card.html new file mode 100644 index 0000000..6e0a449 --- /dev/null +++ b/controlpanel/templates/controlpanel/_club_home_location_card.html @@ -0,0 +1,39 @@ +{% load lucide %} + +{% comment %} + The club's home ground -- an events.Location row flagged is_home, so setting or + editing it here creates/updates the very same Location the club's own Teams > + Locations page shows, no separate sync step involved. Included with `club`, + `home_location`, `home_location_form` already in context. +{% endcomment %} +
Not set yet. Once set, events at this location can be recognised as home games.
+ {% endif %} +