]> git.parisson.com Git - teleforma.git/commitdiff
manage no student.period
authorGuillaume Pellerin <guillaume.pellerin@parisson.com>
Wed, 10 Jan 2024 09:02:54 +0000 (10:02 +0100)
committerGuillaume Pellerin <guillaume.pellerin@parisson.com>
Wed, 10 Jan 2024 09:02:54 +0000 (10:02 +0100)
bin
teleforma/management/commands/teleforma-deactivate-students.py

diff --git a/bin b/bin
index 877deb91a9d035c74bf726fed8851d38e93014ce..52d01bc8d0ec34d96ae3751fa5709a8ae05066fd 160000 (submodule)
--- a/bin
+++ b/bin
@@ -1 +1 @@
-Subproject commit 877deb91a9d035c74bf726fed8851d38e93014ce
+Subproject commit 52d01bc8d0ec34d96ae3751fa5709a8ae05066fd
index b81ac4c4e81edd0bc98b3a561aa6477f68442b41..bd7c7b5450df9999aa7a6fc350430305e4281e08 100644 (file)
@@ -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 #################')