Add billing-ending banner, events CRUD, RBIHF import, public API, team photos, and sponsors
A large batch of club-management features built up over one session: - Club dashboard banner warning admins 1 month before billing ends - Full Events/EventSeries CRUD (recurrence builder, occurrence lifecycle, per-team permissions), with match->game rename and game-specific fields (score, competition, live status, external game ID) - Django-admin competition dropdown, gated per-club by feature flag - Auto-import of RBIHF fixtures (scrape -> diff -> preview -> confirm), with location/opponent dropdowns suggested from existing club data - Feature-flag-gated Shop/Forms nav sections, reusing the same flag machinery for the RBIHF import button - Team roster now scoped to members active this season or next, sorted and grouped by position - Club sport type (ice hockey / other), shown in the control panel's club subtitle - Per-season team photo upload from the team page - New public read-only API (Django Ninja) at /api/v1/: news, team rosters, upcoming/live/per-team games, and sponsors -- auto-documented via Swagger UI, CORS-enabled for a club's own external website - Club sponsors: admin-only CRUD (logo, URL, active date window) plus a date-windowed, optionally randomized API endpoint - Assorted fixes: NullBooleanField dropdown rendering, cross-club event validation timing, searchable-select chip placement, btn-neutral -> default button style sweep, calendar-month chart windows Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R1gj3J1QPfP38XWpnpbFpy
This commit is contained in:
@@ -20,7 +20,7 @@ from events.models import Event
|
||||
from members.models import Family, FamilyMembership, Member
|
||||
from teams.models import Position, StaffAssignment, Team, TeamMembership
|
||||
|
||||
from .models import Club, ClubMembership, ClubRole, FeePayment, Season, club_logo_path
|
||||
from .models import Club, ClubMembership, ClubRole, FeePayment, Season, Sponsor, club_logo_path
|
||||
from .services.access import (
|
||||
COACH_MANAGER,
|
||||
can_edit_event,
|
||||
@@ -464,6 +464,56 @@ class SeasonGetCurrentTests(TestCase):
|
||||
Season.get_current(datetime.date(2026, 12, 25))
|
||||
|
||||
|
||||
class SeasonNextAfterTests(TestCase):
|
||||
def setUp(self):
|
||||
self.club = Club.objects.create(name="Ajax United", slug="ajax-united")
|
||||
self.current = Season.objects.create(club=self.club, start_date=datetime.date(2026, 8, 1), end_date=datetime.date(2027, 5, 31))
|
||||
self.next_season = Season.objects.create(club=self.club, start_date=datetime.date(2027, 8, 1), end_date=datetime.date(2028, 5, 31))
|
||||
|
||||
def test_returns_the_soonest_season_starting_after_the_date(self):
|
||||
self.assertEqual(Season.next_after(self.club, datetime.date(2026, 12, 25)), self.next_season)
|
||||
|
||||
def test_returns_none_when_there_is_no_later_season(self):
|
||||
self.assertIsNone(Season.next_after(self.club, datetime.date(2027, 12, 25)))
|
||||
|
||||
def test_is_scoped_to_the_given_club(self):
|
||||
other = Club.objects.create(name="Rival FC", slug="rival-fc")
|
||||
Season.objects.create(club=other, start_date=datetime.date(2027, 8, 1), end_date=datetime.date(2028, 5, 31))
|
||||
|
||||
self.assertEqual(Season.next_after(other, datetime.date(2026, 12, 25)).club, other)
|
||||
|
||||
|
||||
class SponsorModelTests(TestCase):
|
||||
def setUp(self):
|
||||
self.club = Club.objects.create(name="Ajax United", slug="ajax-united")
|
||||
|
||||
def test_str_returns_name(self):
|
||||
sponsor = Sponsor.objects.create(club=self.club, name="Acme Corp", start_date=datetime.date(2026, 1, 1))
|
||||
|
||||
self.assertEqual(str(sponsor), "Acme Corp")
|
||||
|
||||
def test_a_blank_end_date_is_valid(self):
|
||||
sponsor = Sponsor(club=self.club, name="Acme Corp", start_date=datetime.date(2026, 1, 1))
|
||||
sponsor.full_clean()
|
||||
|
||||
def test_an_end_date_on_the_same_day_as_start_is_valid(self):
|
||||
sponsor = Sponsor(club=self.club, name="Acme Corp", start_date=datetime.date(2026, 1, 1), end_date=datetime.date(2026, 1, 1))
|
||||
sponsor.full_clean()
|
||||
|
||||
def test_an_end_date_before_start_is_rejected(self):
|
||||
sponsor = Sponsor(club=self.club, name="Acme Corp", start_date=datetime.date(2026, 6, 1), end_date=datetime.date(2026, 1, 1))
|
||||
|
||||
with self.assertRaises(ValidationError) as ctx:
|
||||
sponsor.full_clean()
|
||||
self.assertIn("end_date", ctx.exception.error_dict)
|
||||
|
||||
def test_sponsors_are_ordered_by_name(self):
|
||||
Sponsor.objects.create(club=self.club, name="Zulu Corp", start_date=datetime.date(2026, 1, 1))
|
||||
Sponsor.objects.create(club=self.club, name="Acme Corp", start_date=datetime.date(2026, 1, 1))
|
||||
|
||||
self.assertEqual(list(Sponsor.objects.values_list("name", flat=True)), ["Acme Corp", "Zulu Corp"])
|
||||
|
||||
|
||||
class AdminRegistrationSmokeTests(TestCase):
|
||||
"""Every registered model across all apps must have a working admin: load
|
||||
each changelist and add page to catch bad list_display / search_fields /
|
||||
|
||||
Reference in New Issue
Block a user