]> git.parisson.com Git - teleforma.git/commitdiff
Fixed manage commands for new django
authorGael Le Mignot <gael@pilotsystems.net>
Fri, 11 Jun 2021 08:28:15 +0000 (10:28 +0200)
committerGael Le Mignot <gael@pilotsystems.net>
Fri, 11 Jun 2021 08:28:15 +0000 (10:28 +0200)
teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py
teleforma/management/commands/teleforma-send-subscription-email.py
teleforma/management/commands/teleforma-students-activate.py

index 6366fbb421f0c0f3577a2a70ad21371e8e535069..3459d28443237da308520074ae7ad4f1e6c68489 100644 (file)
@@ -31,6 +31,10 @@ class Command(BaseCommand):
     subject_template = 'postman/email_user_subject_init.txt'
     language_code = 'fr_FR'
 
+    def add_arguments(self, parser):
+        parser.add_argument('period_name')
+        parser.add_argument('log_file')
+        
     def init_password_email(self, user):
         site = Site.objects.get_current()
         ctx_dict = {'site': site, 'organization': settings.TELEFORMA_ORGANIZATION, 'usr': user}
@@ -40,8 +44,8 @@ class Command(BaseCommand):
         send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [user.email], fail_silently=False)
 
     def handle(self, *args, **options):
-        log_file = args[-1]
-        period_name = args[-2]
+        log_file = options['log_file']
+        period_name = options['period_name']
         logger = Logger(log_file)
         logger.logger.info('########### Processing #############')
 
index 07631101a2a9565a791b2bf55e46edc883f97f3a..37dc627e78366b99f87b3ed02060db4f4d53ea42 100644 (file)
@@ -29,6 +29,10 @@ class Command(BaseCommand):
     help = "Send an email to new subscribed student"
     language_code = 'fr_FR'
 
+    def add_arguments(self, parser):
+        parser.add_argument('period_name')
+        parser.add_argument('log_file')
+        
     def email(self, student):
         site = Site.objects.get_current()
         if student.platform_only:
@@ -47,8 +51,8 @@ class Command(BaseCommand):
         send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [student.user.email], fail_silently=False)
 
     def handle(self, *args, **options):
-        log_file = args[-1]
-        period_name = args[-2]
+        log_file = options['log_file']
+        period_name = options['period_name']
         logger = Logger(log_file)
         logger.logger.info('########### Processing #############')
 
index 16be2daa63047e6cb8aad457a058adfaa7684d6e..350263d7179828ac96526fbe51daaf19b51b580b 100644 (file)
@@ -28,9 +28,14 @@ class Logger:
 class Command(BaseCommand):
     help = "Activate all user account for subscribed students"
 
+    def add_arguments(self, parser):
+        parser.add_argument('period_name')
+        parser.add_argument('log_file')
+        
+    
     def handle(self, *args, **options):
-        period_name = args[-2]
-        log_file = args[-1]
+        log_file = options['log_file']
+        period_name = options['period_name']
         logger = Logger(log_file)
         logger.logger.info('########### Processing #############')
         users = User.objects.all()