From df9d765d53e0d4be8eba3ef15d3e99ac77999574 Mon Sep 17 00:00:00 2001 From: thomasl Date: Sat, 25 Jan 2025 14:14:23 +0100 Subject: [PATCH] Update file extract_ml_registrations.py --- .../commands/extract_ml_registrations.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/management/commands/extract_ml_registrations.py b/management/commands/extract_ml_registrations.py index c98f48f..37ffa2a 100644 --- a/management/commands/extract_ml_registrations.py +++ b/management/commands/extract_ml_registrations.py @@ -6,6 +6,7 @@ from datetime import date from django.contrib.auth.models import User from django.core.management import BaseCommand from member.models import Club, Membership +from django.core.mail import send_mail class Command(BaseCommand): @@ -54,10 +55,24 @@ class Command(BaseCommand): if options["type"] == "art": nb=0 + emails = [] for user in User.objects.filter(profile__ml_art_registration=True).all(): - self.stdout.write(user.email) + # self.stdout.write(user.email) + emails.append(user.email) nb+=1 - self.stdout.write(str(nb)) + # self.stdout.write(str(nb)) + + subject = "Liste des abonnés à la newsletter BDA" + message = ( + f"Voici la liste des utilisateurs abonnés à la newsletter BDA:\n\n" + + "\n".join(emails) + + f"\n\nTotal des abonnés : {nb}" + ) + from_email = "Note Kfet 2020 " + recipient_list = ["sorties.bda@lists.crans.org"] + + send_mail(subject, message, from_email, recipient_list) + return if options["type"] == "sport":