]> git.parisson.com Git - teleforma.git/commitdiff
fix no user
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 13 Jan 2022 17:05:07 +0000 (18:05 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 13 Jan 2022 17:05:07 +0000 (18:05 +0100)
teleforma/management/commands/teleforma-deactivate-students.py

index 02e87b703f43ad417f5ac87675097f74cc46911c..65d7f38146bf1b2869af9ae9905479ef37b5bcca 100644 (file)
@@ -44,9 +44,10 @@ class Command(BaseCommand):
         translation.activate(self.language_code)
 
         for student in students:
-            if student.is_subscribed and student.confirmation_sent and student.user.email and student.user.is_active:
-                student.user.is_active = False
-                student.user.save()
-                logger.logger.info('deactivated : ' + student.user.username)
+            if hasattr(student, 'user'):
+                if student.is_subscribed and student.confirmation_sent and student.user.email and student.user.is_active:
+                    student.user.is_active = False
+                    student.user.save()
+                    logger.logger.info('deactivated : ' + student.user.username)
 
         logger.logger.info('############## Done #################')