From 151cb3465b862f81735c53aa48f70e168e2c33b4 Mon Sep 17 00:00:00 2001 From: Yoan Le Clanche Date: Thu, 21 Jan 2021 17:00:58 +0100 Subject: [PATCH] Users are now restricted instead of being disabled when accounts is expired to allow them to pay https://trackers.pilotsystems.net/probarreau/1044 --- teleforma/management/commands/teleforma-close-accounts.py | 4 ++-- teleforma/views/payment.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/teleforma/management/commands/teleforma-close-accounts.py b/teleforma/management/commands/teleforma-close-accounts.py index 3ae3cf56..59452003 100644 --- a/teleforma/management/commands/teleforma-close-accounts.py +++ b/teleforma/management/commands/teleforma-close-accounts.py @@ -12,5 +12,5 @@ class Command(BaseCommand): for period in Period.objects.filter(date_close_accounts__lte = 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() + student.restricted = True + student.save() diff --git a/teleforma/views/payment.py b/teleforma/views/payment.py index 4559d869..41e38707 100644 --- a/teleforma/views/payment.py +++ b/teleforma/views/payment.py @@ -111,7 +111,9 @@ def bank_auto(request, merchant_id): payment.online_paid = True payment.date_paid = datetime.datetime.now() if payment.student.restricted: - payment.student.restricted = False + student = payment.student + if student.period.date_close_accounts > datetime.date.today(): + student.restricted = False # send mail data = { 'mfrom': settings.DEFAULT_FROM_EMAIL, @@ -121,7 +123,7 @@ def bank_auto(request, merchant_id): message = render_to_string('teleforma/messages/email_account_activated.txt', data) send_mail("Inscription à la formation Pré-Barreau", message, data['mfrom'], [ data['mto'] ], fail_silently=False) - payment.student.save() + student.save() payment.save() log.info('bank_auto validating order_id %s' % (order_id)) -- 2.39.5