mirror of
				https://gitlab.crans.org/bde/nk20-scripts
				synced 2025-10-31 07:09:52 +01:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			e0b623d5a4
			...
			6752dea48c
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 6752dea48c | 
| @@ -22,8 +22,6 @@ class Command(BaseCommand): | |||||||
|                                  'events mailing list.') |                                  'events mailing list.') | ||||||
|         parser.add_argument('--years', '-y', type=int, default=0,  |         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') |                             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): |     def handle(self, *args, **options): | ||||||
|         # TODO: Improve the mailing list extraction system, and link it automatically with Mailman. |         # TODO: Improve the mailing list extraction system, and link it automatically with Mailman. | ||||||
| @@ -48,51 +46,21 @@ 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 listn, as well as the number of mails. |         # Get the list of mails that want to be registered to the events mailing list. | ||||||
|         # 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": | ||||||
|             nb=0 |  | ||||||
|  |  | ||||||
|             if options["email"] == "": |  | ||||||
|             for user in User.objects.filter(profile__ml_events_registration=options["lang"]).all(): |             for user in User.objects.filter(profile__ml_events_registration=options["lang"]).all(): | ||||||
|                 self.stdout.write(user.email) |                 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": | ||||||
|             nb=0 |             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 = [] |             emails = [] | ||||||
|             for user in User.objects.filter(profile__ml_art_registration=True).all(): |             for user in User.objects.filter(profile__ml_art_registration=True).all(): | ||||||
|  |                 # self.stdout.write(user.email) | ||||||
|                 emails.append(user.email) |                 emails.append(user.email) | ||||||
|                 nb+=1 |                 nb+=1 | ||||||
|  |             # self.stdout.write(str(nb)) | ||||||
|  |  | ||||||
|             subject = "Liste des abonnés à la newsletter BDA" |             subject = "Liste des abonnés à la newsletter BDA" | ||||||
|             message = ( |             message = ( | ||||||
| @@ -101,36 +69,13 @@ 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 = [options["email"]]  |             recipient_list = ["bda.ensparissaclay@gmail.com"]  | ||||||
|  |  | ||||||
|             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": | ||||||
|             nb=0 |  | ||||||
|  |  | ||||||
|             if options["email"] == "": |  | ||||||
|             for user in User.objects.filter(profile__ml_sport_registration=True).all(): |             for user in User.objects.filter(profile__ml_sport_registration=True).all(): | ||||||
|                 self.stdout.write(user.email) |                 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 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user