From 34d8e516261ec8874a92b366d3624bbd7eb2e24c Mon Sep 17 00:00:00 2001 From: Karl Determe Date: Fri, 14 Aug 2026 21:59:00 +0200 Subject: [PATCH] feat: implement daily intervention summary email and unread notification reminders with associated settings and workflow views --- .../commands/send_daily_intervention_summary.py | 2 +- streetup/interventions/views/workflow.py | 8 ++++---- .../commands/send_unread_notification_reminders.py | 10 +++++++--- streetup/streetup/settings.py | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/streetup/interventions/management/commands/send_daily_intervention_summary.py b/streetup/interventions/management/commands/send_daily_intervention_summary.py index c4df54b..8aed21a 100644 --- a/streetup/interventions/management/commands/send_daily_intervention_summary.py +++ b/streetup/interventions/management/commands/send_daily_intervention_summary.py @@ -255,7 +255,7 @@ class Command(BaseCommand): ] body = "\n".join(body_lines) - from_email = getattr(settings, "DEFAULT_FROM_EMAIL", 'no-reply@streetup.be') + from_email = getattr(settings, "DEFAULT_FROM_EMAIL", 'StreetUp no-reply ') email = EmailMultiAlternatives( subject=subject, diff --git a/streetup/interventions/views/workflow.py b/streetup/interventions/views/workflow.py index 06fe964..732accd 100644 --- a/streetup/interventions/views/workflow.py +++ b/streetup/interventions/views/workflow.py @@ -820,7 +820,7 @@ def attempt_status_update(request, intervention, user, new_status, pause_reason= # html_body = render_to_string("emails/new_intervention.html", context) - from_email = getattr(settings, "DEFAULT_FROM_EMAIL", 'no-reply@streetup.be') + from_email = getattr(settings, "DEFAULT_FROM_EMAIL", 'StreetUp no-reply ') reply_to = [] # Récupérer les autres pièces jointes déjà liées à l'intervention @@ -1011,7 +1011,7 @@ def attempt_status_update(request, intervention, user, new_status, pause_reason= text_body = render_to_string("emails/intervention_canceled.txt", context) - from_email = getattr(settings, "DEFAULT_FROM_EMAIL", 'no-reply@streetup.be') + from_email = getattr(settings, "DEFAULT_FROM_EMAIL", 'StreetUp no-reply ') reply_to = [] existing_attachments = get_intervention_attachments( @@ -1243,7 +1243,7 @@ def send_intervention_reminder(request, intervention_id): text_body = render_to_string("emails/intervention_reminder.txt", context) - from_email = getattr(settings, "DEFAULT_FROM_EMAIL", 'no-reply@streetup.be') + from_email = getattr(settings, "DEFAULT_FROM_EMAIL", 'StreetUp no-reply ') reply_to = [] existing_attachments = get_intervention_attachments( @@ -1381,7 +1381,7 @@ def send_intervention_modification(request, intervention_id): text_body = render_to_string("emails/intervention_modification.txt", context) - from_email = getattr(settings, "DEFAULT_FROM_EMAIL", 'no-reply@streetup.be') + from_email = getattr(settings, "DEFAULT_FROM_EMAIL", 'StreetUp no-reply ') reply_to = [] existing_attachments = get_intervention_attachments( diff --git a/streetup/notifications/management/commands/send_unread_notification_reminders.py b/streetup/notifications/management/commands/send_unread_notification_reminders.py index 462ad1c..c05b50a 100644 --- a/streetup/notifications/management/commands/send_unread_notification_reminders.py +++ b/streetup/notifications/management/commands/send_unread_notification_reminders.py @@ -92,7 +92,7 @@ class Command(BaseCommand): subject = f"[StreetUp] Rappel : {count} notification(s) non lue(s)" # Host URL pour les liens - domain = getattr(settings, 'SITE_URL', 'http://localhost:8003') + domain = (getattr(settings, 'ROOT_URL', '') or getattr(settings, 'SITE_URL', '') or 'http://localhost:8000').rstrip('/') lines_text = [ f"Bonjour {user.get_full_name() or user.username},\n", @@ -104,7 +104,11 @@ class Command(BaseCommand): n = r.notification created_str = n.created_at.strftime('%d/%m/%Y à %H:%M') sender_str = n.sender.get_full_name() if n.sender else _("Système") - link = f"{domain}{n.action_url}" if n.action_url else f"{domain}/notifications/" + if n.action_url: + action_path = n.action_url if n.action_url.startswith('/') else f"/{n.action_url}" + link = f"{domain}{action_path}" + else: + link = f"{domain}/notifications/" lines_text.append(f"- [{n.get_notification_type_display()}] {n.title} (reçue le {created_str} par {sender_str})") lines_text.append(f" Lien: {link}\n") @@ -143,7 +147,7 @@ class Command(BaseCommand): msg = EmailMultiAlternatives( subject=subject, body=text_body, - from_email=getattr(settings, 'DEFAULT_FROM_EMAIL', 'noreply@streetup.be'), + from_email=getattr(settings, 'DEFAULT_FROM_EMAIL', 'StreetUp no-reply '), to=recipient_emails, ) msg.attach_alternative(html_body, "text/html") diff --git a/streetup/streetup/settings.py b/streetup/streetup/settings.py index 43c8803..4f7cafd 100644 --- a/streetup/streetup/settings.py +++ b/streetup/streetup/settings.py @@ -239,7 +239,7 @@ EMAIL_USE_SSL = True EMAIL_PORT = getenv("EMAIL_PORT") EMAIL_HOST_USER = getenv("EMAIL_HOST_USER") EMAIL_HOST_PASSWORD = getenv("EMAIL_HOST_PASSWORD") -DEFAULT_FROM_EMAIL = 'no-reply@streetup.be' +DEFAULT_FROM_EMAIL = getenv("DEFAULT_FROM_EMAIL", "StreetUp no-reply ") # Override email recipients for testing (set to None in production) # If set, all emails will be sent to this address instead of real recipients