#82: Merged fix of r364 from default branch into 1.2-dev branch.

This commit is contained in:
Emanuel Schuetze 2012-04-02 08:36:22 +02:00
parent 9c13667ff0
commit 84e5b3d061
4 changed files with 11 additions and 8 deletions

View File

@ -34,6 +34,7 @@ class Profile(models.Model):
group = models.CharField(max_length=100, null=True, blank=True, verbose_name = _("Group"))
type = models.CharField(max_length=100, choices=TYPE_CHOICE, blank=True, verbose_name = _("Typ"))
committee = models.CharField(max_length=100, null=True, blank=True, verbose_name = _("Committee"))
comment = models.CharField(max_length=255, null=True, blank=True, verbose_name = _("Comment"))
firstpassword = models.CharField(max_length=100, null=True, blank=True, verbose_name = _("First Password"))

View File

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

View File

@ -61,8 +61,7 @@
<th><a href="?sort=type&reverse={% if 'type' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "Type" %}</a></th>
<th><a href="?sort=committee&reverse={% if 'committee' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "Committee" %}</a></th>
{% if perms.participant.can_manage_participant %}
<th><a href="?sort=username&reverse={% if 'username' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "Username" %}</a></th>
<th><a href="?sort=email&reverse={% if 'email' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "Email" %}</a></th>
<th><a href="?sort=comment&reverse={% if 'comment' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "Comment" %}</a></th>
<th><a href="?sort=last_login&reverse={% if 'last_login' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{%trans "Last Login" %}</a></th>
<th>{%trans "Actions" %}</th>
{% endif %}
@ -75,8 +74,7 @@
<td>{{ user.profile.get_type_display }}</td>
<td>{{ user.profile.committee }}</td>
{% if perms.participant.can_manage_participant %}
<td>{{ user.username }}</td>
<td>{{ user.email }}</td>
<td>{{ user.profile.comment }}</td>
<td>{% if user.last_login > user.date_joined %}
{{ user.last_login }}
{% endif %}</td>

View File

@ -83,9 +83,9 @@ def get_overview(request):
if 'status' in sortfilter:
query = query.filter(is_active=sortfilter['status'][0])
if 'sort' in sortfilter:
if sortfilter['sort'][0] in ['first_name', 'last_name','username','last_login','email']:
if sortfilter['sort'][0] in ['first_name', 'last_name', 'last_login']:
query = query.order_by(sortfilter['sort'][0])
elif sortfilter['sort'][0] in ['group', 'type', 'committee']:
elif sortfilter['sort'][0] in ['group', 'type', 'committee', 'comment']:
query = query.order_by('profile__%s' % sortfilter['sort'][0])
else:
query = query.order_by('first_name')
@ -339,7 +339,7 @@ def user_import(request):
for line in csv.reader(request.FILES['csvfile'], dialect=dialect):
i += 1
if i > 0:
(first_name, last_name, gender, group, type, committee) = line[:6]
(first_name, last_name, gender, group, type, committee, comment) = line[:7]
user = User()
user.last_name = last_name
user.first_name = first_name
@ -352,6 +352,7 @@ def user_import(request):
profile.group = group
profile.type = type
profile.committee = committee
profile.comment = comment
profile.firstpassword = gen_password()
profile.user.set_password(profile.firstpassword)
profile.save()
@ -364,6 +365,7 @@ def user_import(request):
user.groups.add(observer)
messages.success(request, _('%d new participants were successfully imported.') % i)
return redirect(reverse('user_overview'))
except csv.Error:
message.error(request, _('Import aborted because of severe errors in the input file.'))
else: