From 307a664c65a1bd14461cbc0b6b45323241f64428 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 13 Jan 2022 18:05:07 +0100 Subject: [PATCH] fix no user --- .../management/commands/teleforma-deactivate-students.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 #################') -- 2.39.5