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()
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'