]> git.parisson.com Git - teleforma.git/commitdiff
no pass upgrade
authorGuillaume Pellerin <yomguy@parisson.com>
Fri, 11 Jul 2014 16:45:57 +0000 (18:45 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Fri, 11 Jul 2014 16:45:57 +0000 (18:45 +0200)
teleforma/management/commands/teleforma-init-wifi-pass.py
teleforma/models/crfpa.py

index 8d8f4b3b6e40a8469c43ced203a41c98b885ff65..25f5e5f3f9e653c3e36d036304f89adf04f87c14 100644 (file)
@@ -10,15 +10,18 @@ import logging
 import codecs
 import random, string
 
+
 def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
-       return ''.join(random.choice(chars) for _ in range(size))
+    return ''.join(random.choice(chars) for _ in range(size))
+
 
 class Command(BaseCommand):
     help = "init all user wifi pass"
 
     def handle(self, *args, **options):
-       for user in User.objects.all():
-               profile = user.profile.get()
-               profile.wifi_login = user.username + '.' + args[-1]
-               profile.wifi_pass = id_generator(8)
-               profile.save()
+        for user in User.objects.all():
+            profile = user.profile.get()
+            if not profile.wifi_pass:
+                profile.wifi_login = user.username + '.' + args[-1]
+                profile.wifi_pass = id_generator(8)
+                profile.save()
index d89eede2531647ef3bd670e2896320950d5c7624..39f75f4fb75cd82ba98c2a2cbb6195f8b68107f4 100644 (file)
@@ -155,8 +155,8 @@ class Profile(models.Model):
     telephone       = CharField(_('Telephone'), max_length=255, blank=True)
     expiration_date = DateField(_('Expiration_date'), blank=True, null=True)
     init_password   = BooleanField(_('Password initialized'))
-    wifi_login      = CharField(_('WiFi login (ICP)'), max_length=255, blank=True)
-    wifi_pass       = CharField(_('WiFi pass (ICP)'), max_length=255, blank=True)
+    wifi_login      = CharField(_('WiFi login'), max_length=255, blank=True)
+    wifi_pass       = CharField(_('WiFi pass'), max_length=255, blank=True)
 
     class Meta(MetaCore):
         db_table = app_label + '_' + 'profiles'