mirror of
https://gitlab.crans.org/bde/nk20-scripts
synced 2025-04-27 18:02:36 +00:00
Compare commits
3 Commits
6752dea48c
...
e0b623d5a4
Author | SHA1 | Date | |
---|---|---|---|
|
e0b623d5a4 | ||
|
3dd5f6e3e0 | ||
|
735d90e482 |
@ -22,6 +22,8 @@ class Command(BaseCommand):
|
||||
'events mailing list.')
|
||||
parser.add_argument('--years', '-y', type=int, default=0,
|
||||
help='Select the cumulative registred users of a membership from years ago. 0 means the current users')
|
||||
parser.add_argument('--email', '-e', type=str, default="",
|
||||
help='Put the email supposed to receive the emails of the mailing list (only for art). If nothing is put, the script will just print the emails.')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# TODO: Improve the mailing list extraction system, and link it automatically with Mailman.
|
||||
@ -46,21 +48,51 @@ class Command(BaseCommand):
|
||||
self.stdout.write(club.email)
|
||||
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.
|
||||
if options["type"] == "events":
|
||||
nb=0
|
||||
|
||||
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
|
||||
|
||||
if options["type"] == "art":
|
||||
nb=0
|
||||
|
||||
if options["email"] == "":
|
||||
for user in User.objects.filter(profile__ml_art_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_art_registration=True).all():
|
||||
# self.stdout.write(user.email)
|
||||
emails.append(user.email)
|
||||
nb+=1
|
||||
# self.stdout.write(str(nb))
|
||||
|
||||
subject = "Liste des abonnés à la newsletter BDA"
|
||||
message = (
|
||||
@ -69,13 +101,36 @@ class Command(BaseCommand):
|
||||
+ f"\n\nTotal des abonnés : {nb}"
|
||||
)
|
||||
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)
|
||||
|
||||
return
|
||||
|
||||
if options["type"] == "sport":
|
||||
nb=0
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user