From d6ed011c7021a8cb3ae8229aeda54b18956e48ed Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 23 Jun 2022 18:46:38 +0200 Subject: [PATCH] fix wifi pass generation, fix export --- .../commands/teleforma-export-wifi-accounts.py | 9 +++------ .../management/commands/teleforma-init-wifi-pass.py | 11 ----------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/teleforma/management/commands/teleforma-export-wifi-accounts.py b/teleforma/management/commands/teleforma-export-wifi-accounts.py index a2674c2d..23984144 100644 --- a/teleforma/management/commands/teleforma-export-wifi-accounts.py +++ b/teleforma/management/commands/teleforma-export-wifi-accounts.py @@ -30,18 +30,15 @@ class Command(BaseCommand): if profile and students: p = profile[0] student = students[0] - if student.is_subscribed and user.is_active and student.period == period: + if student.is_subscribed and user.is_active and \ + student.period == period and student.platform_only: data = [] data.append(user.first_name) data.append(user.last_name) - data.append(str(period.date_begin)) - data.append(str(period.date_end)) - data.append(str(period.date_begin)) - data.append(str(period.date_end)) data.append(p.wifi_login) data.append(p.wifi_pass) data.append('\n') s = ','.join(data) - f.write(s.encode('utf8')) + f.write(s) f.close() diff --git a/teleforma/management/commands/teleforma-init-wifi-pass.py b/teleforma/management/commands/teleforma-init-wifi-pass.py index 55118909..0c4f3422 100644 --- a/teleforma/management/commands/teleforma-init-wifi-pass.py +++ b/teleforma/management/commands/teleforma-init-wifi-pass.py @@ -15,15 +15,8 @@ def id_generator(size=6, chars=string.ascii_uppercase + string.digits): 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') - for user in User.objects.all(): try: profile = user.profile.get() @@ -31,9 +24,5 @@ class Command(BaseCommand): profile.wifi_login = user.username profile.wifi_pass = id_generator(8) profile.save() - f.write(user.first_name + ',' + user.last_name + ',' + - profile.wifi_login + ',' + profile.wifi_pass + '\n') except: continue - - f.close() -- 2.39.5