]> git.parisson.com Git - teleforma.git/commitdiff
fix wifi pass generation, fix export
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 23 Jun 2022 16:46:38 +0000 (18:46 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 23 Jun 2022 16:46:38 +0000 (18:46 +0200)
teleforma/management/commands/teleforma-export-wifi-accounts.py
teleforma/management/commands/teleforma-init-wifi-pass.py

index a2674c2dbb4d7ad12fc1b4b92c08eae5d3c4e362..23984144960b7355e676530474adaebfcd4d0626 100644 (file)
@@ -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()
 
index 5511890980d88fd26c39f59128db21054f67ac95..0c4f3422edf2f62996977bfc7ebd37861113cb9a 100644 (file)
@@ -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()