]> git.parisson.com Git - teleforma.git/commitdiff
Added script to close accounts
authorGael Le Mignot <gael@pilotsystems.net>
Tue, 13 Nov 2018 15:43:55 +0000 (16:43 +0100)
committerGael Le Mignot <gael@pilotsystems.net>
Tue, 13 Nov 2018 15:43:55 +0000 (16:43 +0100)
teleforma/management/commands/teleforma-close-accounts.py [new file with mode: 0644]

diff --git a/teleforma/management/commands/teleforma-close-accounts.py b/teleforma/management/commands/teleforma-close-accounts.py
new file mode 100644 (file)
index 0000000..697cd7e
--- /dev/null
@@ -0,0 +1,16 @@
+from django.conf import settings
+from django.core.management.base import BaseCommand, CommandError
+from teleforma.models import *
+import datetime
+
+class Command(BaseCommand):
+    help = "Close account of students tied to expired periods"
+    admin_email = 'webmaster@parisson.com'
+
+    def handle(self, *args, **options):
+        today = datetime.date.today()
+        for period in Period.objects.filter(date_close_accounts__gte = today):
+            for student in period.student.filter(user__is_active = True):
+                print "Closing %s %s" % (student, student.user_id)
+                student.user.is_active = False
+                student.user.save()