From d952677c0e1f93bf5bdd64d348522ae2d2e32796 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Fri, 11 Jul 2014 18:45:57 +0200 Subject: [PATCH] no pass upgrade --- .../commands/teleforma-init-wifi-pass.py | 15 +++++++++------ teleforma/models/crfpa.py | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/teleforma/management/commands/teleforma-init-wifi-pass.py b/teleforma/management/commands/teleforma-init-wifi-pass.py index 8d8f4b3b..25f5e5f3 100644 --- a/teleforma/management/commands/teleforma-init-wifi-pass.py +++ b/teleforma/management/commands/teleforma-init-wifi-pass.py @@ -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() diff --git a/teleforma/models/crfpa.py b/teleforma/models/crfpa.py index d89eede2..39f75f4f 100644 --- a/teleforma/models/crfpa.py +++ b/teleforma/models/crfpa.py @@ -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' -- 2.39.5