From d934ed112c71bd02171cea606855fc03619db7de Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Wed, 10 Jan 2024 10:02:54 +0100 Subject: [PATCH] manage no student.period --- bin | 2 +- .../commands/teleforma-deactivate-students.py | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/bin b/bin index 877deb91..52d01bc8 160000 --- a/bin +++ b/bin @@ -1 +1 @@ -Subproject commit 877deb91a9d035c74bf726fed8851d38e93014ce +Subproject commit 52d01bc8d0ec34d96ae3751fa5709a8ae05066fd diff --git a/teleforma/management/commands/teleforma-deactivate-students.py b/teleforma/management/commands/teleforma-deactivate-students.py index b81ac4c4..bd7c7b54 100644 --- a/teleforma/management/commands/teleforma-deactivate-students.py +++ b/teleforma/management/commands/teleforma-deactivate-students.py @@ -40,17 +40,23 @@ class Command(BaseCommand): logger.logger.info('########### Processing #############') today = datetime.date.today() - students = Student.objects.filter(period=period) + students = Student.objects.all() translation.activate(self.language_code) for student in students: - if student.user: - if student.is_subscribed and student.confirmation_sent and \ - student.user.email and student.user.is_active and \ - student.period.date_close_accounts <= today: - - student.user.is_active = False - student.user.save() - logger.logger.info('deactivated : ' + student.user.username) + print(student) + try: + if student.user.email and student.user.is_active: + if student.period: + if student.period.date_close_accounts <= today: + student.user.is_active = False + student.user.save() + logger.logger.info('deactivated : ' + student.user.username) + else: + student.user.is_active = False + student.user.save() + logger.logger.info('deactivated : ' + student.user.username) + except: + continue logger.logger.info('############## Done #################') -- 2.39.5