Commit 9493cf92 authored by fred's avatar fred

load-csv-users: update to match new csv file format

parent d171bcae
...@@ -13,18 +13,19 @@ class Command(BaseCommand): ...@@ -13,18 +13,19 @@ class Command(BaseCommand):
def handle(self, filename, verbosity, **kwargs): def handle(self, filename, verbosity, **kwargs):
self.verbose = (verbosity > 1) self.verbose = (verbosity > 1)
for line in csv.reader(file(filename)): for line in csv.reader(file(filename)):
lastname, firstname, email = [unicode(x.strip(), 'utf-8') for x in line[:3]] email, lastname, firstname = [unicode(x.strip(), 'utf-8') for x in line[:3]]
emission_slugs = [x.strip().lower() for x in line[6:] if x] emission_slugs = [x.strip().lower() for x in line[4:9] if x]
if not email or not emission_slugs: if not email or not emission_slugs:
continue continue
if firstname and lastname: if firstname and lastname:
username = slugify(u'%s-%s' % (firstname, lastname)) username = slugify(u'%s-%s' % (firstname, lastname))
elif firstname or lastname: elif firstname or lastname:
username = slugify(firstname or lastname) username = slugify(firstname or lastname)
if len(username) < 8:
username = '%s.%s' % (username, slugify(unicode(emission_slugs[0])))
else: else:
continue continue
print username, email, emission_slugs
try: try:
user = User.objects.get(username=username) user = User.objects.get(username=username)
except User.DoesNotExist: except User.DoesNotExist:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment