]> git.parisson.com Git - teleforma.git/commitdiff
fix account init
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Fri, 5 Feb 2016 09:48:17 +0000 (10:48 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Fri, 5 Feb 2016 09:48:17 +0000 (10:48 +0100)
teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py
teleforma/management/commands/teleforma-send-subscription-email.py

index 3d4cc9171e9a069d121f313a1c9106995cf84647..fc21978d9d7a19dd10dfb64ea5f1643261330a94 100644 (file)
@@ -43,18 +43,24 @@ class Command(BaseCommand):
 
     def handle(self, *args, **options):
         log_file = args[-1]
+        period_name = args[-2]
         logger = Logger(log_file)
         logger.logger.info('########### Processing #############')
 
+        period = Period.objects.get(name=period_name)
         users = User.objects.all()
         translation.activate(self.language_code)
 
         for user in users:
             profile, c = Profile.objects.get_or_create(user=user)
             students = user.student.all()
+            if students:
+                student = students[0]
+            else:
+                student = Student()
             professors = user.professor.all()
             quotas = user.quotas.all()
-            if students or professors or quotas:
+            if student.period == period or professors or quotas:
                 if profile and user.is_active:
                     if not profile.init_password and user.email:
                         self.init_password_email(user)
index 965393d18ab78523f54657eef26173b1c1d950a8..5011ccac6b2a1e441f795e49d6aa147a1db03806 100644 (file)
@@ -56,7 +56,7 @@ class Command(BaseCommand):
         translation.activate(self.language_code)
 
         for student in students:
-            if student.is_subscribed and not student.confirmation_sent and student.user.is_active and student.user.email and student.period == period:
+            if student.is_subscribed and not student.confirmation_sent and student.user.email and student.period == period:
                 self.email(student)
                 student.confirmation_sent = True
                 student.save()