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:
90
events/competition/hockey.py
Normal file
90
events/competition/hockey.py
Normal file
@@ -0,0 +1,90 @@
|
||||
from urllib.parse import urljoin
|
||||
|
||||
import requests
|
||||
|
||||
from ..models import Event
|
||||
from .base import CompetitionBaseClass
|
||||
|
||||
|
||||
class RBIHF(CompetitionBaseClass):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.url = "https://rbihf.be/modules/league/ajax/time.php"
|
||||
|
||||
def update_game_information(self, event: Event) -> None:
|
||||
season = "{start}{end}".format(start=event.season.start_date.strftime("%y"), end=event.season.end_date.strftime("%y"))
|
||||
|
||||
payload = {"gameNr": event.external_game_id, "season": season}
|
||||
headers = {
|
||||
"Cookie": "language=en",
|
||||
"Postman-Token": "rosterchief",
|
||||
"Host": "www.rbihf.be",
|
||||
"User-Agent": "PostmanRuntime/7.37.0",
|
||||
"Accept": "application/json",
|
||||
"Accept-Encoding": "gzip,deflate,br",
|
||||
"Connection": "keep-alive",
|
||||
"Referer": f"https://rbihf.be/game/{event.external_game_id}",
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
}
|
||||
|
||||
req = requests.get(self.url, params=payload, headers=headers)
|
||||
|
||||
if req.status_code == 200:
|
||||
game_data = req.json()
|
||||
|
||||
event.is_live = game_data["live"]
|
||||
|
||||
if event.is_home_game:
|
||||
event.score_for = game_data["scoreA"]
|
||||
event.score_against = game_data["scoreB"]
|
||||
else:
|
||||
event.score_for = game_data["scoreB"]
|
||||
event.score_against = game_data["scoreA"]
|
||||
|
||||
event.save(update_fields=["is_live", "score_for", "score_against"])
|
||||
|
||||
|
||||
class CEHL(CompetitionBaseClass):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.url = "https://www.cehl.eu/ajax/"
|
||||
|
||||
def update_game_information(self, event: Event) -> None:
|
||||
season = "{start}{end}".format(start=event.season.start_date.strftime("%y"), end=event.season.end_date.strftime("%y"))
|
||||
|
||||
referer_url = urljoin("https://www.cehl.eu", f"game/{season}/{event.external_game_id}")
|
||||
timeline_url = urljoin(self.url, "timeline.php")
|
||||
score_url = urljoin(self.url, "score.php")
|
||||
|
||||
payload = {"nr": event.external_game_id, "season": season}
|
||||
headers = {
|
||||
"Cookie": "language=en",
|
||||
"Postman-Token": "rosterchief",
|
||||
"Host": "www.cehl.eu",
|
||||
"User-Agent": "PostmanRuntime/7.37.0",
|
||||
"Accept": "*/*",
|
||||
"Accept-Encoding": "gzip,deflate,br",
|
||||
"Connection": "close",
|
||||
"Referer": referer_url,
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
}
|
||||
|
||||
timeline_req = requests.get(timeline_url, params=payload, headers=headers)
|
||||
score_req = requests.get(score_url, params=payload, headers=headers)
|
||||
|
||||
if timeline_req.status_code == 200:
|
||||
event.is_live = timeline_req.json()["live"] == 1
|
||||
|
||||
if score_req.status_code == 200:
|
||||
game_data = score_req.json()
|
||||
|
||||
if event.is_home_game:
|
||||
event.score_for = game_data["scoreA"]
|
||||
event.score_against = game_data["scoreB"]
|
||||
|
||||
else:
|
||||
event.score_for = game_data["scoreB"]
|
||||
event.score_against = game_data["scoreA"]
|
||||
|
||||
if timeline_req.status_code == 200 or score_req.status_code == 200:
|
||||
event.save(update_fields=["is_live", "score_for", "score_against"])
|
||||
Reference in New Issue
Block a user