From: yomguy Date: Tue, 12 Jun 2012 23:58:52 +0000 (+0200) Subject: fix same username X-Git-Tag: 0.5.4~7 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f08342b9a756ab710b80d70611dac8f2bb3f3609;p=teleforma.git fix same username --- diff --git a/teleforma/management/commands/teleforma-import-users-pb.py b/teleforma/management/commands/teleforma-import-users-pb.py index 23693343..b33d378b 100644 --- a/teleforma/management/commands/teleforma-import-users-pb.py +++ b/teleforma/management/commands/teleforma-import-users-pb.py @@ -50,6 +50,15 @@ class Command(BaseCommand): email = row[9].value username = slugify(first_name)[0] + '.' + slugify(last_name) username = username[:30] + users = User.objects.filter(username=username) + i = 1 + while users: + username = slugify(first_name)[i] + '.' + slugify(last_name) + users = User.objects.filter(username=username) + if not users: + break + i += 1 + date = row[14].value date_joined = datetime.datetime(*xlrd.xldate_as_tuple(date, self.book.datemode))