From: Gael Le Mignot Date: Tue, 13 Nov 2018 15:43:55 +0000 (+0100) Subject: Added script to close accounts X-Git-Tag: 1.4.0~21^2~5 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=cdcc42b46873fb2fd95752dd51357233e5cddf29;p=teleforma.git Added script to close accounts --- 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()