1
0
mirror of https://gitlab.crans.org/bde/nk20-scripts synced 2025-04-20 14:42:13 +00:00

Extend the possibility to send the list by email to the other newsletters

This commit is contained in:
thomasl 2025-03-04 16:50:49 +01:00
parent 735d90e482
commit 3dd5f6e3e0

View File

@ -48,11 +48,35 @@ class Command(BaseCommand):
self.stdout.write(club.email) self.stdout.write(club.email)
return return
# Get the list of mails that want to be registered to the events mailing list. # Get the list of mails that want to be registered to the events mailing listn, as well as the number of mails.
# Print it or send it to the email provided by the user.
# Don't filter to valid members, old members can receive these mails as long as they want. # Don't filter to valid members, old members can receive these mails as long as they want.
if options["type"] == "events": if options["type"] == "events":
for user in User.objects.filter(profile__ml_events_registration=options["lang"]).all(): nb=0
self.stdout.write(user.email)
if options["email"] == "":
for user in User.objects.filter(profile__ml_events_registration=options["lang"]).all():
self.stdout.write(user.email)
nb+=1
self.stdout.write(str(nb))
else :
emails = []
for user in User.objects.filter(profile__ml_events_registration=options["lang"]).all():
emails.append(user.email)
nb+=1
subject = "Liste des abonnés à la newsletter BDE"
message = (
f"Voici la liste des utilisateurs abonnés à la newsletter BDE:\n\n"
+ "\n".join(emails)
+ f"\n\nTotal des abonnés : {nb}"
)
from_email = "Note Kfet 2020 <notekfet2020@crans.org>"
recipient_list = [options["email"]]
send_mail(subject, message, from_email, recipient_list)
return return
if options["type"] == "art": if options["type"] == "art":
@ -77,13 +101,36 @@ class Command(BaseCommand):
+ f"\n\nTotal des abonnés : {nb}" + f"\n\nTotal des abonnés : {nb}"
) )
from_email = "Note Kfet 2020 <notekfet2020@crans.org>" from_email = "Note Kfet 2020 <notekfet2020@crans.org>"
recipient_list = ["bda.ensparissaclay@gmail.com"] recipient_list = [options["email"]]
send_mail(subject, message, from_email, recipient_list) send_mail(subject, message, from_email, recipient_list)
return return
if options["type"] == "sport": if options["type"] == "sport":
for user in User.objects.filter(profile__ml_sport_registration=True).all(): nb=0
self.stdout.write(user.email)
if options["email"] == "":
for user in User.objects.filter(profile__ml_sport_registration=True).all():
self.stdout.write(user.email)
nb+=1
self.stdout.write(str(nb))
else :
emails = []
for user in User.objects.filter(profile__ml_sport_registration=True).all():
emails.append(user.email)
nb+=1
subject = "Liste des abonnés à la newsletter BDS"
message = (
f"Voici la liste des utilisateurs abonnés à la newsletter BDS:\n\n"
+ "\n".join(emails)
+ f"\n\nTotal des abonnés : {nb}"
)
from_email = "Note Kfet 2020 <notekfet2020@crans.org>"
recipient_list = [options["email"]]
send_mail(subject, message, from_email, recipient_list)
return return