From: Guillaume Pellerin Date: Wed, 23 Jun 2021 05:15:03 +0000 (+0200) Subject: add add_arguments method to all commands X-Git-Tag: 2.1~66^2^2~8^2 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=eeda61d1477d5617b0e27c13666cc805ac350f29;p=teleforma.git add add_arguments method to all commands --- diff --git a/teleforma/management/commands/teleforma-broadcast-message.py b/teleforma/management/commands/teleforma-broadcast-message.py index bc61e6fc..8c3ca50d 100644 --- a/teleforma/management/commands/teleforma-broadcast-message.py +++ b/teleforma/management/commands/teleforma-broadcast-message.py @@ -9,6 +9,9 @@ class Command(BaseCommand): help = "Broadcast a chat message" args = "username text" + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def handle(self, *args, **options): # text = args[1] # username = args[0] diff --git a/teleforma/management/commands/teleforma-change-period-of-content.py b/teleforma/management/commands/teleforma-change-period-of-content.py index 68931a1d..728eefcb 100644 --- a/teleforma/management/commands/teleforma-change-period-of-content.py +++ b/teleforma/management/commands/teleforma-change-period-of-content.py @@ -12,6 +12,9 @@ class Command(BaseCommand): args = "period_id_from period_id_to year" admin_email = 'webmaster@parisson.com' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def handle(self, *args, **options): period_from_id = args[0] period_to_id = args[1] diff --git a/teleforma/management/commands/teleforma-delete-period-conferences.py b/teleforma/management/commands/teleforma-delete-period-conferences.py index ede413d5..010b1df2 100644 --- a/teleforma/management/commands/teleforma-delete-period-conferences.py +++ b/teleforma/management/commands/teleforma-delete-period-conferences.py @@ -11,6 +11,9 @@ class Command(BaseCommand): args = "period_name" admin_email = 'webmaster@parisson.com' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def handle(self, *args, **options): period_name = args[0] period = Period.objects.get(name=period_name) diff --git a/teleforma/management/commands/teleforma-delete-users.py b/teleforma/management/commands/teleforma-delete-users.py index 518839f4..3c8fe6ff 100644 --- a/teleforma/management/commands/teleforma-delete-users.py +++ b/teleforma/management/commands/teleforma-delete-users.py @@ -12,6 +12,9 @@ class Command(BaseCommand): args = "date1 date2" admin_email = 'webmaster@parisson.com' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def export_user(self, count, user): if student: diff --git a/teleforma/management/commands/teleforma-exam-submit-scripts.py b/teleforma/management/commands/teleforma-exam-submit-scripts.py index 3c642961..b902b6fe 100644 --- a/teleforma/management/commands/teleforma-exam-submit-scripts.py +++ b/teleforma/management/commands/teleforma-exam-submit-scripts.py @@ -28,6 +28,9 @@ class Command(BaseCommand): help = "submit all script to Box View" args = "log_file" + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def handle(self, *args, **options): translation.activate(settings.LANGUAGE_CODE) logger = Logger(args[0]) diff --git a/teleforma/management/commands/teleforma-export-professors.py b/teleforma/management/commands/teleforma-export-professors.py index 4b7d620b..bde16224 100644 --- a/teleforma/management/commands/teleforma-export-professors.py +++ b/teleforma/management/commands/teleforma-export-professors.py @@ -27,6 +27,8 @@ class Command(BaseCommand): print 'exported: ' + user.first_name + ' ' + user.last_name + ' ' + user.username return json.dumps(list) + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') def handle(self, *args, **options): file = args[0] diff --git a/teleforma/management/commands/teleforma-export-stream-m-slugs.py b/teleforma/management/commands/teleforma-export-stream-m-slugs.py index 794598a9..2ca48472 100644 --- a/teleforma/management/commands/teleforma-export-stream-m-slugs.py +++ b/teleforma/management/commands/teleforma-export-stream-m-slugs.py @@ -27,6 +27,9 @@ streams.safe.password=source2parisson streams.safe.limit=100 """ + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def export(self): courses = Course.objects.all() types = CourseType.objects.all() diff --git a/teleforma/management/commands/teleforma-export-users.py b/teleforma/management/commands/teleforma-export-users.py index 0824939c..eff4dd17 100644 --- a/teleforma/management/commands/teleforma-export-users.py +++ b/teleforma/management/commands/teleforma-export-users.py @@ -9,6 +9,9 @@ class Command(BaseCommand): first_row = 1 admin_email = 'webmaster@parisson.com' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def export_user(self, count, user): student = Student.objects.filter(user=user) if student: diff --git a/teleforma/management/commands/teleforma-export-wifi-accounts.py b/teleforma/management/commands/teleforma-export-wifi-accounts.py index 197a1898..86135fb7 100644 --- a/teleforma/management/commands/teleforma-export-wifi-accounts.py +++ b/teleforma/management/commands/teleforma-export-wifi-accounts.py @@ -12,6 +12,9 @@ class Command(BaseCommand): help = "Export all WiFi accounts" args = 'path' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def handle(self, *args, **options): path = args[0] period_name = args[1] diff --git a/teleforma/management/commands/teleforma-import-conferences-create.py b/teleforma/management/commands/teleforma-import-conferences-create.py index 95477fe6..b87cc3a0 100644 --- a/teleforma/management/commands/teleforma-import-conferences-create.py +++ b/teleforma/management/commands/teleforma-import-conferences-create.py @@ -33,6 +33,9 @@ class Command(BaseCommand): transcoded_formats = ['mp4', 'ogg', 'mp3'] image_formats = ['png', 'jpg'] + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def cleanup(self): medias = Media.objects.all() for media in medias: diff --git a/teleforma/management/commands/teleforma-import-courses-xls.py b/teleforma/management/commands/teleforma-import-courses-xls.py index 3a6009ec..a56575f2 100644 --- a/teleforma/management/commands/teleforma-import-courses-xls.py +++ b/teleforma/management/commands/teleforma-import-courses-xls.py @@ -16,6 +16,9 @@ class Command(BaseCommand): first_row = 2 admin_email = 'webmaster@parisson.com' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def handle(self, *args, **options): organization = args[0] path = args[1] diff --git a/teleforma/management/commands/teleforma-import-courses.py b/teleforma/management/commands/teleforma-import-courses.py index 18cd3f07..852a1fc6 100644 --- a/teleforma/management/commands/teleforma-import-courses.py +++ b/teleforma/management/commands/teleforma-import-courses.py @@ -12,6 +12,9 @@ class Command(BaseCommand): args = "organization path" admin_email = 'webmaster@parisson.com' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def handle(self, *args, **options): organization = args[0] path = args[1] diff --git a/teleforma/management/commands/teleforma-import-professors.py b/teleforma/management/commands/teleforma-import-professors.py index 55f20596..d925a1a5 100644 --- a/teleforma/management/commands/teleforma-import-professors.py +++ b/teleforma/management/commands/teleforma-import-professors.py @@ -13,6 +13,8 @@ class Command(BaseCommand): args = "path" admin_email = 'webmaster@parisson.com' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') def import_professors(self, data): professors = json.loads(data) diff --git a/teleforma/management/commands/teleforma-import-seminar-media.py b/teleforma/management/commands/teleforma-import-seminar-media.py index 31491b01..04ce8f43 100644 --- a/teleforma/management/commands/teleforma-import-seminar-media.py +++ b/teleforma/management/commands/teleforma-import-seminar-media.py @@ -33,6 +33,9 @@ class Command(BaseCommand): image_formats = ['png', 'jpg'] media_rank_dict = {'bis': 2, 'ter': 3, 'quarter': 4, 'quinquies': 5, 'quater': 4} + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def cleanup(self): items = MediaItemTranscoded.objects.all() for i in items : diff --git a/teleforma/management/commands/teleforma-import-students-from-xls.py b/teleforma/management/commands/teleforma-import-students-from-xls.py index 16fe6141..ddbf84c4 100644 --- a/teleforma/management/commands/teleforma-import-students-from-xls.py +++ b/teleforma/management/commands/teleforma-import-students-from-xls.py @@ -14,6 +14,9 @@ class Command(BaseCommand): args = "path" admin_email = 'webmaster@parisson.com' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def handle(self, *args, **options): file = args[0] period = args[1] diff --git a/teleforma/management/commands/teleforma-import-users-pb-debug.py b/teleforma/management/commands/teleforma-import-users-pb-debug.py index 10c5a3c7..c70ae1da 100644 --- a/teleforma/management/commands/teleforma-import-users-pb-debug.py +++ b/teleforma/management/commands/teleforma-import-users-pb-debug.py @@ -22,6 +22,9 @@ class Command(BaseCommand): else: return None + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def get_training(self, code): platform_only = False if 'I' in code[0:2]: diff --git a/teleforma/management/commands/teleforma-import-users-pb-fix.py b/teleforma/management/commands/teleforma-import-users-pb-fix.py index a8372591..d8c5d3ae 100644 --- a/teleforma/management/commands/teleforma-import-users-pb-fix.py +++ b/teleforma/management/commands/teleforma-import-users-pb-fix.py @@ -17,6 +17,9 @@ class Command(BaseCommand): admin_email = 'webmaster@parisson.com' DEBUG = True + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def get_courses(self, code): courses = Course.objects.filter(code=code) if courses: diff --git a/teleforma/management/commands/teleforma-import-users-pb.py b/teleforma/management/commands/teleforma-import-users-pb.py index e12209d5..dfe165a7 100644 --- a/teleforma/management/commands/teleforma-import-users-pb.py +++ b/teleforma/management/commands/teleforma-import-users-pb.py @@ -17,6 +17,9 @@ class Command(BaseCommand): admin_email = 'webmaster@parisson.com' DEBUG = True + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def get_courses(self, code): courses = Course.objects.filter(code=code) if courses: diff --git a/teleforma/management/commands/teleforma-import-users.py b/teleforma/management/commands/teleforma-import-users.py index e523fef0..894664e2 100644 --- a/teleforma/management/commands/teleforma-import-users.py +++ b/teleforma/management/commands/teleforma-import-users.py @@ -15,6 +15,9 @@ class Command(BaseCommand): first_row = 2 admin_email = 'webmaster@parisson.com' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def get_first_course(self, code): courses = Course.objects.filter(code=code) if courses: diff --git a/teleforma/management/commands/teleforma-init-wifi-pass.py b/teleforma/management/commands/teleforma-init-wifi-pass.py index 8ecc3306..55118909 100644 --- a/teleforma/management/commands/teleforma-init-wifi-pass.py +++ b/teleforma/management/commands/teleforma-init-wifi-pass.py @@ -17,6 +17,9 @@ class Command(BaseCommand): help = "init all user wifi pass" args = 'path' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def handle(self, *args, **options): path = args[0] f = open(path, 'w') diff --git a/teleforma/management/commands/teleforma-pull-courses.py b/teleforma/management/commands/teleforma-pull-courses.py index 95ca1cd4..359ba1cf 100644 --- a/teleforma/management/commands/teleforma-pull-courses.py +++ b/teleforma/management/commands/teleforma-pull-courses.py @@ -14,6 +14,9 @@ class Command(BaseCommand): admin_email = 'webmaster@parisson.com' args = "organization_name department_name" + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def handle(self, *args, **options): organization_name = args[0] department_name = args[1] diff --git a/teleforma/management/commands/teleforma-reset-all-passwords-with-mail-fix.py b/teleforma/management/commands/teleforma-reset-all-passwords-with-mail-fix.py index f2aadb5a..26fc3797 100644 --- a/teleforma/management/commands/teleforma-reset-all-passwords-with-mail-fix.py +++ b/teleforma/management/commands/teleforma-reset-all-passwords-with-mail-fix.py @@ -31,6 +31,9 @@ class Command(BaseCommand): subject_template = 'postman/email_user_subject_init.txt' language_code = 'fr_FR' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def init_password_email(self, user): site = Site.objects.get_current() ctx_dict = {'site': site, 'organization': settings.TELEFORMA_ORGANIZATION, 'usr': user} diff --git a/teleforma/management/commands/teleforma-reset-all-passwords-with-mail-test.py b/teleforma/management/commands/teleforma-reset-all-passwords-with-mail-test.py index 30939e7c..93178092 100644 --- a/teleforma/management/commands/teleforma-reset-all-passwords-with-mail-test.py +++ b/teleforma/management/commands/teleforma-reset-all-passwords-with-mail-test.py @@ -32,6 +32,9 @@ class Command(BaseCommand): language_code = 'fr_FR' username = 'test' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def init_password_email(self, user): site = Site.objects.get_current() ctx_dict = {'site': site, 'organization': settings.TELEFORMA_ORGANIZATION, 'usr': user} 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 3459d284..e5e7d3bf 100644 --- a/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py +++ b/teleforma/management/commands/teleforma-reset-all-passwords-with-mail.py @@ -32,9 +32,8 @@ class Command(BaseCommand): language_code = 'fr_FR' def add_arguments(self, parser): - parser.add_argument('period_name') - parser.add_argument('log_file') - + parser.add_argument('args', nargs='*') + def init_password_email(self, user): site = Site.objects.get_current() ctx_dict = {'site': site, 'organization': settings.TELEFORMA_ORGANIZATION, 'usr': user} diff --git a/teleforma/management/commands/teleforma-send-subscription-email-test.py b/teleforma/management/commands/teleforma-send-subscription-email-test.py index 5b196214..531a2705 100644 --- a/teleforma/management/commands/teleforma-send-subscription-email-test.py +++ b/teleforma/management/commands/teleforma-send-subscription-email-test.py @@ -30,6 +30,9 @@ class Command(BaseCommand): language_code = 'fr_FR' username = 'test' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def email(self, student): site = Site.objects.get_current() if student.platform_only: diff --git a/teleforma/management/commands/teleforma-students-activate-test.py b/teleforma/management/commands/teleforma-students-activate-test.py index 4d4aec33..d77c4dbc 100644 --- a/teleforma/management/commands/teleforma-students-activate-test.py +++ b/teleforma/management/commands/teleforma-students-activate-test.py @@ -29,6 +29,9 @@ class Command(BaseCommand): help = "Activate all user account for subscribed students" username = 'test' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def handle(self, *args, **options): period_name = args[-2] log_file = args[-1] diff --git a/teleforma/management/commands/teleforma-students-activate.py b/teleforma/management/commands/teleforma-students-activate.py index 350263d7..234242f0 100644 --- a/teleforma/management/commands/teleforma-students-activate.py +++ b/teleforma/management/commands/teleforma-students-activate.py @@ -31,7 +31,6 @@ class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument('period_name') parser.add_argument('log_file') - def handle(self, *args, **options): log_file = options['log_file'] diff --git a/teleforma/management/commands/teleforma-students-deactivate.py b/teleforma/management/commands/teleforma-students-deactivate.py index 649088c9..17f4ec0e 100644 --- a/teleforma/management/commands/teleforma-students-deactivate.py +++ b/teleforma/management/commands/teleforma-students-deactivate.py @@ -28,6 +28,9 @@ class Logger: class Command(BaseCommand): help = "Activate all user account for subscribed students" + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def handle(self, *args, **options): period_name = args[-2] log_file = args[-1] diff --git a/teleforma/management/commands/teleforma-unpublish-period-content.py b/teleforma/management/commands/teleforma-unpublish-period-content.py index d60b18c8..3b719a63 100644 --- a/teleforma/management/commands/teleforma-unpublish-period-content.py +++ b/teleforma/management/commands/teleforma-unpublish-period-content.py @@ -11,6 +11,9 @@ class Command(BaseCommand): args = "period_name" admin_email = 'webmaster@parisson.com' + def add_arguments(self, parser): + parser.add_argument('args', nargs='*') + def handle(self, *args, **options): period_name = args[0] period = Period.objects.get(name=period_name)