]> git.parisson.com Git - teleforma.git/commitdiff
add period for account activation
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 4 Feb 2016 16:06:56 +0000 (17:06 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 4 Feb 2016 16:06:56 +0000 (17:06 +0100)
teleforma/management/commands/teleforma-students-activate.py

index 0dbe9e7efadf143d644e9f55db3e14fed2303783..9fe557093fba14be6678e4ed8e67ae2a4b9db2c8 100644 (file)
@@ -31,16 +31,18 @@ class Command(BaseCommand):
     help = "Activate all user account for subscribed students"
 
     def handle(self, *args, **options):
+        period_name = args[-2]
         log_file = args[-1]
         logger = Logger(log_file)
         logger.logger.info('########### Processing #############')
         users = User.objects.all()
+        period = Period.objects.get(name=period_name)
 
         for user in users:
             students = user.student.all()
             if students:
                 student = students[0]
-                if student.is_subscribed and not user.is_active:
+                if student.is_subscribed and not user.is_active and student.period == period:
                     user.is_active = True
                     user.save()
                     logger.logger.info('init : ' + user.username)