From cdcc42b46873fb2fd95752dd51357233e5cddf29 Mon Sep 17 00:00:00 2001 From: Gael Le Mignot Date: Tue, 13 Nov 2018 16:43:55 +0100 Subject: [PATCH] Added script to close accounts --- .../commands/teleforma-close-accounts.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 teleforma/management/commands/teleforma-close-accounts.py diff --git a/teleforma/management/commands/teleforma-close-accounts.py b/teleforma/management/commands/teleforma-close-accounts.py new file mode 100644 index 00000000..697cd7e2 --- /dev/null +++ b/teleforma/management/commands/teleforma-close-accounts.py @@ -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() -- 2.39.5