Commit 9493cf92 authored by fred's avatar fred
Browse files

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

parent d171bcae
......@@ -13,18 +13,19 @@ class Command(BaseCommand):
def handle(self, filename, verbosity, **kwargs):
self.verbose = (verbosity > 1)
for line in csv.reader(file(filename)):
lastname, firstname, email = [unicode(x.strip(), 'utf-8') for x in line[:3]]
emission_slugs = [x.strip().lower() for x in line[6:] if x]
email, lastname, firstname = [unicode(x.strip(), 'utf-8') for x in line[:3]]
emission_slugs = [x.strip().lower() for x in line[4:9] if x]
if not email or not emission_slugs:
if firstname and lastname:
username = slugify(u'%s-%s' % (firstname, lastname))
elif firstname or lastname:
username = slugify(firstname or lastname)
if len(username) < 8:
username = '%s.%s' % (username, slugify(unicode(emission_slugs[0])))
print username, email, emission_slugs
user = User.objects.get(username=username)
except User.DoesNotExist:
Supports Markdown
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