mirror of
				https://gitlab.crans.org/bde/nk20-scripts
				synced 2025-11-04 00:32:03 +01:00 
			
		
		
		
	Merge branch 'Send_mail_NL_art' into 'master'
Update file extract_ml_registrations.py See merge request bde/nk20-scripts!6
This commit is contained in:
		@@ -6,6 +6,7 @@ from datetime import date
 | 
				
			|||||||
from django.contrib.auth.models import User
 | 
					from django.contrib.auth.models import User
 | 
				
			||||||
from django.core.management import BaseCommand
 | 
					from django.core.management import BaseCommand
 | 
				
			||||||
from member.models import Club, Membership
 | 
					from member.models import Club, Membership
 | 
				
			||||||
 | 
					from django.core.mail import send_mail
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Command(BaseCommand):
 | 
					class Command(BaseCommand):
 | 
				
			||||||
@@ -54,10 +55,24 @@ class Command(BaseCommand):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if options["type"] == "art":
 | 
					        if options["type"] == "art":
 | 
				
			||||||
            nb=0
 | 
					            nb=0
 | 
				
			||||||
 | 
					            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)
 | 
					                # self.stdout.write(user.email)
 | 
				
			||||||
 | 
					                emails.append(user.email)
 | 
				
			||||||
                nb+=1
 | 
					                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 <notekfet2020@crans.org>" 
 | 
				
			||||||
 | 
					            recipient_list = ["sorties.bda@lists.crans.org"] 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            send_mail(subject, message, from_email, recipient_list)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if options["type"] == "sport":
 | 
					        if options["type"] == "sport":
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user