From: Guillaume Pellerin Date: Thu, 13 Jan 2022 17:05:07 +0000 (+0100) Subject: fix no user X-Git-Tag: 2.5.1~14^2 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=307a664c65a1bd14461cbc0b6b45323241f64428;p=teleforma.git fix no user --- diff --git a/teleforma/management/commands/teleforma-deactivate-students.py b/teleforma/management/commands/teleforma-deactivate-students.py index 02e87b70..65d7f381 100644 --- a/teleforma/management/commands/teleforma-deactivate-students.py +++ b/teleforma/management/commands/teleforma-deactivate-students.py @@ -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 #################')