mirror of
				https://gitlab.crans.org/bde/nk20-scripts
				synced 2025-10-30 22:59:52 +01:00 
			
		
		
		
	Extend the possibility to send the list by email to the other newsletters
This commit is contained in:
		| @@ -48,11 +48,35 @@ 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": | ||||
|             for user in User.objects.filter(profile__ml_events_registration=options["lang"]).all(): | ||||
|                 self.stdout.write(user.email) | ||||
|             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": | ||||
| @@ -77,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": | ||||
|             for user in User.objects.filter(profile__ml_sport_registration=True).all(): | ||||
|                 self.stdout.write(user.email) | ||||
|             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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user