From: Gael Le Mignot Date: Fri, 11 Jun 2021 08:28:15 +0000 (+0200) Subject: Fixed manage commands for new django X-Git-Tag: 2.1~66^2^2~31^2 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=ac70c1ddb304177201520d7f2c41984ccb2efc95;p=teleforma.git Fixed manage commands for new django --- diff --git a/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py b/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py index 6366fbb4..3459d284 100644 --- a/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py +++ b/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py @@ -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 #############') diff --git a/teleforma/management/commands/teleforma-send-subscription-email.py b/teleforma/management/commands/teleforma-send-subscription-email.py index 07631101..37dc627e 100644 --- a/teleforma/management/commands/teleforma-send-subscription-email.py +++ b/teleforma/management/commands/teleforma-send-subscription-email.py @@ -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 #############') diff --git a/teleforma/management/commands/teleforma-students-activate.py b/teleforma/management/commands/teleforma-students-activate.py index 16be2daa..350263d7 100644 --- a/teleforma/management/commands/teleforma-students-activate.py +++ b/teleforma/management/commands/teleforma-students-activate.py @@ -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()