#82: New comment field for participant form (database changes: syncdb required)
This commit is contained in:
parent
beb8694cdc
commit
a8fcba0f69
@ -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"))
|
||||
|
||||
|
||||
|
@ -5,7 +5,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">
|
||||
|
@ -58,8 +58,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 %}
|
||||
@ -72,8 +71,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>
|
||||
|
@ -82,9 +82,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')
|
||||
@ -338,7 +338,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
|
||||
@ -351,6 +351,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()
|
||||
@ -363,6 +364,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:
|
||||
|
Loading…
Reference in New Issue
Block a user