Add group/club-wide event audiences and a Resend email backend
Events can now target members.Group audiences alongside teams, or go club_wide (every ACTIVE ClubMembership member for the event's season) instead of specific teams/groups -- the two are mutually exclusive, enforced in EventForm/EventSeriesForm.clean() since an M2M can't be validated via a DB CheckConstraint or Event.clean() (no PK yet). Attendance sync (events/signals.py) now reacts to GroupMembership and ClubMembership changes the same way it already did for TeamMembership. Authorization: club.services.access.groups_manageable_by mirrors teams_managed_by (all groups for an ADMIN, else only the ones the user belongs to -- Group has no manager/owner concept); a non-admin needs at least one managed team or belonged-to group to create/edit an event, club_wide stays admin-only, and EventManagerRequiredMixin gained a get_groups() hook so a non-admin who creates a group-only event isn't immediately locked out of managing it. Also adds rosterchief.mail.ResendEmailBackend, an HTTP-API-based Django email backend for Resend (resend.com) using the existing `requests` dependency -- no new SDK. Opt in via DJANGO_EMAIL_BACKEND and RESEND_API_KEY; every Django-sent email (allauth's password reset included) follows whichever EMAIL_BACKEND is configured, so this covers all of them for free. Resend's own SMTP relay remains a valid code-free alternative, documented alongside it in .env.production.example. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -335,6 +335,12 @@ LOGGING = {
|
||||
# DEFAULT rather than the dev-only branch -- a deployment that forgets to configure mail
|
||||
# should print billing reminders to the log, not raise ConnectionRefused against localhost:25
|
||||
# on a box with no MTA, which is what Django's own default does.
|
||||
#
|
||||
# Resend (resend.com) works either way: point DJANGO_EMAIL_BACKEND at Django's own SMTP
|
||||
# backend with Resend's SMTP relay credentials, or set it to rosterchief.mail.ResendEmailBackend
|
||||
# to send through Resend's HTTP API instead (see that module) -- set RESEND_API_KEY either way.
|
||||
# Every Django-sent email (allauth's password reset included, since it goes through
|
||||
# django.core.mail like everything else) follows whichever backend is configured here.
|
||||
EMAIL_BACKEND = config("DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend")
|
||||
EMAIL_HOST = config("DJANGO_EMAIL_HOST", default="")
|
||||
EMAIL_PORT = config("DJANGO_EMAIL_PORT", default=587, cast=int)
|
||||
@@ -344,6 +350,10 @@ EMAIL_USE_TLS = config("DJANGO_EMAIL_USE_TLS", default=True, cast=bool)
|
||||
EMAIL_USE_SSL = config("DJANGO_EMAIL_USE_SSL", default=False, cast=bool)
|
||||
EMAIL_TIMEOUT = config("DJANGO_EMAIL_TIMEOUT", default=10, cast=int)
|
||||
|
||||
#: Only read by rosterchief.mail.ResendEmailBackend -- irrelevant for the SMTP backend
|
||||
#: (which would use EMAIL_HOST_PASSWORD, e.g. Resend's own SMTP relay, instead).
|
||||
RESEND_API_KEY = config("RESEND_API_KEY", default="")
|
||||
|
||||
DEFAULT_FROM_EMAIL = config("DJANGO_DEFAULT_FROM_EMAIL", default="RosterChief <noreply@rosterchief.app>")
|
||||
SERVER_EMAIL = config("DJANGO_SERVER_EMAIL", default=DEFAULT_FROM_EMAIL)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user