]> git.parisson.com Git - teleforma.git/commitdiff
Users are now restricted instead of being disabled when accounts is expired to allow...
authorYoan Le Clanche <yoanl@pilotsystems.net>
Thu, 21 Jan 2021 16:00:58 +0000 (17:00 +0100)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Thu, 21 Jan 2021 16:00:58 +0000 (17:00 +0100)
teleforma/management/commands/teleforma-close-accounts.py
teleforma/views/payment.py

index 3ae3cf56cda54eb07709d90b2b219cf1d226de81..59452003278778668a5850d1473e4ef4b38c817e 100644 (file)
@@ -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()
index 4559d869572828e10c74d9664ea22f1403ec660c..41e387071ab99b28359f38188f15bcaf513f98fa 100644 (file)
@@ -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))