reorder user-import csv data

This commit is contained in:
Oskar Hahn 2011-09-05 09:08:12 +02:00
parent c6259d83bb
commit 510cbf8374
2 changed files with 5 additions and 5 deletions

View File

@ -5,7 +5,7 @@
<h1>Import</h1> <h1>Import</h1>
<p>{% trans 'Select a CSV file to import participants!' %}</p> <p>{% trans 'Select a CSV file to import participants!' %}</p>
<p>{% trans '(Required comma separated values: <code>last_name, first_name, email, gender, group, type, committee</code>)' %} </p> <p>{% trans '(Required comma separated values: <code>first_name, last_name, gender, group, type, committee</code>)' %} </p>
<form enctype="multipart/form-data" action="" method="post">{% csrf_token %} <form enctype="multipart/form-data" action="" method="post">{% csrf_token %}
{{ form.as_p }} {{ form.as_p }}
<button type="submit"> <button type="submit">

View File

@ -251,13 +251,13 @@ def user_import(request):
for line in request.FILES['csvfile']: for line in request.FILES['csvfile']:
i += 1 i += 1
if i > 0: if i > 0:
(last_name, first_name, email, gender, group, type, committee) = line.strip().split(',') (first_name, last_name, gender, group, type, committee) = line.strip().split(',')
user = User() user = User()
user.last_name = last_name user.last_name = last_name
user.first_name = first_name user.first_name = first_name
user.username = gen_username(first_name, last_name) user.username = gen_username(first_name, last_name)
user.set_password("%s%s" % (user.first_name, user.last_name)) #user.set_password("%s%s" % (user.first_name, user.last_name))
user.email = email #user.email = email
user.save() user.save()
profile = Profile() profile = Profile()
profile.user = user profile.user = user