From 80baf914cdd71052ca1cbfd389965c0b50c20e86 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Tue, 30 May 2023 09:07:24 +0200 Subject: [PATCH] Hotfix: siae_user.full_name in Siae completion reminder task. Other fixes. ref #753 --- .../management/commands/send_completion_reminder_emails.py | 3 ++- lemarche/siaes/tasks.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lemarche/siaes/management/commands/send_completion_reminder_emails.py b/lemarche/siaes/management/commands/send_completion_reminder_emails.py index 847eab599..8a4a4e143 100644 --- a/lemarche/siaes/management/commands/send_completion_reminder_emails.py +++ b/lemarche/siaes/management/commands/send_completion_reminder_emails.py @@ -1,11 +1,12 @@ import calendar -from django.core.management.base import BaseCommand, CommandError +from django.core.management.base import CommandError from django.utils import timezone from lemarche.siaes.models import Siae from lemarche.siaes.tasks import send_completion_reminder_email_to_siae from lemarche.utils.apis import api_slack +from lemarche.utils.commands import BaseCommand class Command(BaseCommand): diff --git a/lemarche/siaes/tasks.py b/lemarche/siaes/tasks.py index f3f6b650b..17573fd42 100644 --- a/lemarche/siaes/tasks.py +++ b/lemarche/siaes/tasks.py @@ -36,15 +36,16 @@ def set_siae_coords(model, siae): def send_completion_reminder_email_to_siae(siae): email_subject = "Vous avez raté des opportunités commerciales !" - siae_user_emails = siae.users.values_list("email", flat=True) + siae_user_emails = list(siae.users.values_list("email", flat=True)) recipient_list = whitelist_recipient_list(siae_user_emails) if recipient_list: for siae_user_email in recipient_list: - siae_user = User.objects.get(email=siae_user_email).first_name + siae_user = User.objects.get(email=siae_user_email) recipient_name = siae_user.full_name variables = { "SIAE_USER_FIRST_NAME": siae_user.first_name, + "SIAE_NAME": siae.name_display, "SIAE_URL": get_share_url_object(siae), "SIAE_EDIT_URL": f"https://{get_domain_url()}{reverse_lazy('dashboard:siae_edit_contact', args=[siae.slug])}", # noqa }