Fix the referee PDF's card background, make locations searchable, and add game end times to the API
Referee PDF: the info-card background used CSS color-mix(), which WeasyPrint doesn't support -- the rule was silently dropped, leaving the card with no background at all. Computed in Python instead (management/pdf.py) and baked into the template as a plain hex value; the tint is based on the club's primary_color, falling back to secondary_color when primary is itself (near) black or white, where a straight tint would be invisible or too harsh. Event forms: the location picker now shows "Name — City" (plus the country when it isn't Belgium) and is searchable by name or city, reusing the existing single-select searchable-select.js widget. Games API: GameOut now carries `end` (explicit, or start + 2h when a GAME was saved without one -- Event.save() sets this, never overwriting an explicit end; other event kinds are untouched). /games/upcoming/ now includes anything not yet finished rather than only things that haven't started, so a game already in progress keeps showing up until its window closes; `status` was adjusted to match so a game returned there never calls itself "finished". Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
26
api/tests.py
26
api/tests.py
@@ -356,6 +356,32 @@ class GamesApiTests(ApiTestBase):
|
||||
|
||||
self.assertEqual(self.api_get("/games/upcoming/").json(), [])
|
||||
|
||||
def test_upcoming_includes_a_game_already_in_progress(self):
|
||||
# Started 30 minutes ago, no explicit end -- the assumed 2h window
|
||||
# means it isn't finished yet, so it must still show up.
|
||||
self.make_game(start=timezone.now() - datetime.timedelta(minutes=30))
|
||||
|
||||
games = self.api_get("/games/upcoming/").json()
|
||||
|
||||
self.assertEqual(len(games), 1)
|
||||
self.assertEqual(games[0]["status"], "live")
|
||||
|
||||
def test_upcoming_excludes_a_game_past_its_explicit_end(self):
|
||||
game = self.make_game(start=timezone.now() - datetime.timedelta(hours=3))
|
||||
game.end = timezone.now() - datetime.timedelta(hours=1)
|
||||
game.save()
|
||||
|
||||
self.assertEqual(self.api_get("/games/upcoming/").json(), [])
|
||||
|
||||
def test_the_response_includes_an_end_time(self):
|
||||
game = self.make_game()
|
||||
|
||||
end = self.api_get("/games/upcoming/").json()[0]["end"]
|
||||
|
||||
# JSON round-trips to millisecond precision -- compare with a small
|
||||
# tolerance rather than an exact microsecond match.
|
||||
self.assertLess(abs((datetime.datetime.fromisoformat(end) - game.end).total_seconds()), 1)
|
||||
|
||||
def test_upcoming_includes_tournaments(self):
|
||||
self.make_game(kind=Event.EventKind.TOURNAMENT)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user