Restore per-leader routing with configurable email addresses

Previously routing was hardcoded (Andrea for indoor, Barbara for outdoor).
Then it was replaced with a flat ADMIN_EMAILS list which lost the routing.
This commit restores routing via three separate env vars:

  ADMIN_EMAIL_INDOOR  — indoor leader, To when indoor days are booked
  ADMIN_EMAIL_OUTDOOR — outdoor leader, To when outdoor days are booked
  ADMIN_EMAIL_CC      — always Cc'd (comma-separated for multiple)

For testing, set all three to your own address so no real leader gets mail.

Changes:
- Config: replaced admin_emails with admin_email_indoor/outdoor/cc fields
- AdminNotifier: replaced admin_emails param with indoor_email/outdoor_email/
  cc_emails; _recipients_for() restored as an instance method using these
- main.py: wires the three new config fields into AdminNotifier
- .env.example: documents the three new variables with production defaults
- Tests: fixture updated to use new params

https://claude.ai/code/session_01HaUFs7SaLD5SoiuGCY27Tw
This commit is contained in:
Claude
2026-02-21 21:31:49 +00:00
parent 7fb1d1fa0f
commit db97a357c9
5 changed files with 59 additions and 28 deletions
+9 -9
View File
@@ -32,10 +32,12 @@ class Config:
# Registration email address shown to parents
registration_email: str = ""
# Admin notification recipients (comma-separated).
# First address → To; remaining addresses → Cc.
# Set to a single address (e.g. your own) during testing.
admin_emails: list = field(default_factory=list)
# Admin notification routing.
# Each leader receives mail only when a day in their group is booked.
# For testing, point all three to your own address.
admin_email_indoor: str = "" # Indoor leader (Andrea Sigrist) — To when indoor booked
admin_email_outdoor: str = "" # Outdoor leader (Barbara Gross) — To when outdoor booked
admin_email_cc: str = "" # Always Cc'd (Markus Graf / admin); comma-separated if multiple
# Storage
data_dir: Path = field(default_factory=lambda: Path("data"))
@@ -61,11 +63,9 @@ class Config:
smtp_port=int(os.getenv("SMTP_PORT", "587")),
smtp_use_tls=os.getenv("SMTP_USE_TLS", "true").lower() == "true",
registration_email=os.getenv("REGISTRATION_EMAIL", ""),
admin_emails=[
e.strip()
for e in os.getenv("ADMIN_EMAILS", "").split(",")
if e.strip()
],
admin_email_indoor=os.getenv("ADMIN_EMAIL_INDOOR", ""),
admin_email_outdoor=os.getenv("ADMIN_EMAIL_OUTDOOR", ""),
admin_email_cc=os.getenv("ADMIN_EMAIL_CC", ""),
data_dir=Path(os.getenv("DATA_DIR", "data")),
knowledge_base_dir=Path(
os.getenv(