Add a news review workflow and a staff notification area

News gains a PENDING_REVIEW status between draft and published. A
non-editor author (can_add_news but not can_publish_news -- a
coach_manager, not an ADMIN/EDITOR) gets a "Send for review" button
instead of Publish; an editor/admin always sees Publish directly, no
review step. Submitting notifies every ADMIN/EDITOR in-app only (see
notify_members' new send_email=False) -- a review queue that emailed
on every submission would get noisy fast.

The notification area itself: a topbar bell (badge + dropdown, same
<details>/<summary> convention as the sidebar's user-menu, generalised
to a shared .dismissable-details close handler) visible on every page,
plus a fuller "Notifications" card on the dashboard, both fed by a new
notification_bell context processor. "Mark all read" clears the
signed-in staff member's own unread notifications for this club.

This is the reusable notification system's first consumer beyond news
publishing itself -- validates that notify_members()/Notification
generalise the way they were meant to.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ECGMEwrc2k4D8VQuwjstj9
This commit is contained in:
2026-08-21 09:52:59 +02:00
parent 20a44a915f
commit 0ecdeac354
16 changed files with 421 additions and 26 deletions

View File

@@ -51,19 +51,23 @@ def _send_email(notification: Notification, emails: list[str]) -> None:
continue
def notify_members(members, *, club, title: str, body: str, source=None) -> list[Notification]:
"""One Notification per member, emailed to everyone recipient_emails()
resolves for them. Always creates the row, even when nobody was reachable
-- that's still true history for a future in-app feed, not a failure to
silently drop."""
def notify_members(members, *, club, title: str, body: str, source=None, send_email: bool = True) -> list[Notification]:
"""One Notification per member. Emailed to everyone recipient_emails()
resolves for them, unless send_email is False -- e.g. a staff review
queue (see news.services.notify_editors_of_pending_review), which is
in-app only: it doesn't need every editor emailed on every submission,
just the topbar/dashboard entry. Always creates the row, even when
nobody was reachable or emailing was skipped -- that's still true
history for the in-app feed, not a failure to silently drop."""
notifications = []
for member in members:
notification = Notification.objects.create(club=club, member=member, title=title, body=body, source=source)
emails = recipient_emails(member)
if emails:
_send_email(notification, emails)
notification.sent_at = timezone.now()
notification.sent_to_emails = emails
notification.save(update_fields=["sent_at", "sent_to_emails", "modified"])
if send_email:
emails = recipient_emails(member)
if emails:
_send_email(notification, emails)
notification.sent_at = timezone.now()
notification.sent_to_emails = emails
notification.save(update_fields=["sent_at", "sent_to_emails", "modified"])
notifications.append(notification)
return notifications