Add a club event-background photo, shown in black & white on event heroes
New Club.event_background, uploaded from the identity page. Individual events have no photo of their own (an established, deliberate scope decision for this build), so this is the one club-wide stand-in for the photo the design canvas's own hero mockups call for -- shown under the same dark gradient the hero already used, filtered to grayscale so it never fights the club's own brand colours. Falls back to the existing plain dark background when nothing's uploaded. Applied to both event hero treatments: M2's own event-detail screen (the "big black thing" this was reported against) and Home's "next up" card. The image and gradient are separate absolutely-positioned layers behind a z-10 content wrapper, not a filter on the card itself, so the grayscale treatment never touches the text/buttons drawn on top of it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ECGMEwrc2k4D8VQuwjstj9
This commit is contained in:
@@ -2,6 +2,7 @@ import datetime
|
||||
from decimal import Decimal
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.test import TestCase, override_settings
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone, translation
|
||||
@@ -19,6 +20,12 @@ from .services.icons import render_fallback_icon
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
ONE_PIXEL_PNG = b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15\xc4\x89\x00\x00\x00\nIDATx\x9cc\x00\x01\x00\x00\x05\x00\x01\r\n-\xb4\x00\x00\x00\x00IEND\xaeB`\x82"
|
||||
|
||||
|
||||
def make_image_file(name="photo.png"):
|
||||
return SimpleUploadedFile(name, ONE_PIXEL_PNG, content_type="image/png")
|
||||
|
||||
|
||||
def make_club(**kwargs):
|
||||
return Club.objects.create(name="Ajax United", slug="ajax-united", secondary_color="#e4002b", **kwargs)
|
||||
@@ -231,6 +238,17 @@ class HomeViewTests(TestCase):
|
||||
self.assertEqual(response.context["hero_attendance"].event, soon)
|
||||
self.assertContains(response, "Away")
|
||||
|
||||
def test_hero_shows_the_clubs_event_background_in_grayscale_when_set(self):
|
||||
event = self.make_event(title="Practice")
|
||||
Attendance.objects.create(event=event, member=self.member)
|
||||
self.club.event_background = make_image_file()
|
||||
self.club.save(update_fields=["event_background"])
|
||||
self.client.force_login(self.user)
|
||||
|
||||
response = self._get("home")
|
||||
|
||||
self.assertContains(response, 'class="absolute inset-0 h-full w-full object-cover grayscale"')
|
||||
|
||||
def test_hero_is_absent_when_no_upcoming_event(self):
|
||||
self.client.force_login(self.user)
|
||||
|
||||
@@ -764,6 +782,23 @@ class EventDetailScreenTests(TestCase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, "Home game")
|
||||
|
||||
def test_hero_shows_the_clubs_event_background_in_grayscale_when_set(self):
|
||||
self.club.event_background = make_image_file()
|
||||
self.club.save(update_fields=["event_background"])
|
||||
self.client.force_login(self.user)
|
||||
|
||||
response = self._get()
|
||||
|
||||
self.assertContains(response, 'class="absolute inset-0 h-full w-full object-cover grayscale"')
|
||||
self.assertContains(response, self.club.event_background.url)
|
||||
|
||||
def test_hero_has_no_background_image_when_the_club_has_not_set_one(self):
|
||||
self.client.force_login(self.user)
|
||||
|
||||
response = self._get()
|
||||
|
||||
self.assertNotContains(response, "grayscale")
|
||||
|
||||
def test_rsvp_buttons_are_replaced_by_a_readonly_pill_once_the_deadline_has_passed(self):
|
||||
closed_event = Event.objects.create(club=self.club, title="Closed game", start=timezone.now() + datetime.timedelta(days=3), deadline=timezone.now() - datetime.timedelta(hours=1))
|
||||
Attendance.objects.create(event=closed_event, member=self.member, status=Attendance.AttendanceStatus.NO_RESPONSE)
|
||||
|
||||
Reference in New Issue
Block a user