Adjusted new template for participant app. Added new generic form.

This commit is contained in:
Emanuel Schuetze 2012-09-06 22:41:24 +02:00
parent 8da28310f7
commit 7c90206b3f
16 changed files with 184 additions and 193 deletions

View File

@ -1,30 +0,0 @@
{% extends "base.html" %}
{% load tags %}
{% load i18n %}
{% load staticfiles %}
{% block submenu %}
{% url user_overview as url_users %}
{% url user_new as url_usernew %}
{% url user_group_overview as url_usergroups %}
{% url user_import as url_userimport %}
<h4 class="sectiontitle">{% trans "Participants" %}</h4>
<ul>
{% if perms.participant.can_see_participant %}
<li class="{% if request.path == url_users %}selected{% endif %}"><a href="{% url user_overview %}">{% trans "All participants" %}</a></li>
{% endif %}
{% if perms.participant.can_manage_participant %}
<li class="{% active request url_usernew %}"><a href="{% url user_new %}">{% trans "New participant" %}</a></li>
<li class="{% if request.path == url_usergroups %}selected{% endif %}"><a href="{% url user_group_overview %}">{% trans "All user groups" %}</a></li>
<li class="{% active request '/participant/group/new' %}"><a href="{% url user_group_new %}">{% trans "New user group" %}</a></li>
<li class="{% if request.path == url_userimport %}selected{% endif %}"><a href="{% url user_import %}"> {% trans 'Import participants' %}</a></li>
{% endif %}
{% if perms.participant.can_see_participant %}
<li><a href="{% url user_print %}"><img src="{% static 'images/icons/pdf.png' %}"> {% trans 'List of participants as PDF' %}</a></li>
{% endif %}
{% if perms.participant.can_manage_participant %}
<li><a href="{% url print_passwords %}"><img src="{% static 'images/icons/pdf.png' %}"> {% trans 'First time passwords as PDF' %}</a></li>
{% endif %}
</ul>
{% endblock %}

View File

@ -7,15 +7,11 @@
{% block content %}
<h1>{% trans "Participant settings" %}</h1>
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
{% include "form.html" %}
<p>
<button class="button" type="submit">
<span class="icon ok">{% trans 'Save' %}</span>
</button>
<a href='{% url config_application %}'>
<button class="button" type="button" onclick="window.location='{% url config_application %}'">
<span class="icon cancel">{% trans 'Cancel' %}</span>
</button>
{% include "formbuttons_save.html" %}
<a href='{% url config_application %}' class="btn">
{% trans 'Cancel' %}
</a>
</p>
</form>

View File

@ -1,4 +1,4 @@
{% extends "participant/base_participant.html" %}
{% extends "base.html" %}
{% load i18n %}
@ -11,32 +11,29 @@
{% endif %}
{% endblock %}
{% block content %}
<h1>
{% if edit_user %}
<h1>{% trans "Edit participant" %}</h1>
{% trans "Edit participant" %}
{% else %}
<h1>{% trans "New participant" %}</h1>
{% trans "New participant" %}
{% endif %}
<small class="pull-right">
<a href="{% url user_overview %}" class="btn btn-mini"><i class="icon-chevron-left"></i> {% trans "Back to overview" %}</a>
</small>
</h1>
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
{% include "form.html" %}
{% if edit_user %}
<p>
<a href="{% url user_reset_password edit_user.id %}">{% trans 'Reset to First Password' %}</a>
</p>
{% endif %}
<p>
<button class="button" type="submit">
<span class="icon ok">{% trans 'Save' %}</span>
</button>
<button class="button" type="submit" name="apply">
<span class="icon apply">{% trans 'Apply' %}</span>
</button>
<a href='{% url user_overview %}'>
<button class="button" type="button" onclick="window.location='{% url user_overview %}'">
<span class="icon cancel">{% trans 'Cancel' %}</span>
</button>
{% include "formbuttons_saveapply.html" %}
<a href='{% url user_overview %}' class="btn">
{% trans 'Cancel' %}
</a>
</p>
<small>* {% trans "required" %}</small>

View File

@ -1,4 +1,4 @@
{% extends "participant/base_participant.html" %}
{% extends "base.html" %}
{% load i18n %}
@ -12,25 +12,23 @@
{% endblock %}
{% block content %}
<h1>
{% if group %}
<h1>{% trans "Edit user group" %}</h1>
{% trans "Edit user group" %}
{% else %}
<h1>{% trans "New user group" %}</h1>
{% trans "New user group" %}
{% endif %}
<small class="pull-right">
<a href="{% url user_group_overview %}" class="btn btn-mini"><i class="icon-chevron-left"></i> {% trans "Back to overview" %}</a>
</small>
</h1>
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
{% include "form.html" %}
<p>
<button class="button" type="submit">
<span class="icon ok">{% trans 'Save' %}</span>
</button>
<button class="button" type="submit" name="apply">
<span class="icon apply">{% trans 'Apply' %}</span>
</button>
<a href='{% url user_group_overview %}'>
<button class="button" type="button" onclick="window.location='{% url user_group_overview %}'">
<span class="icon cancel">{% trans 'Cancel' %}</span>
</button>
{% include "formbuttons_saveapply.html" %}
<a href='{% url user_group_overview %}' class="btn">
{% trans 'Cancel' %}
</a>
</p>
<small>* {% trans "required" %}</small>

View File

@ -1,4 +1,4 @@
{% extends "participant/base_participant.html" %}
{% extends "base.html" %}
{% load i18n %}
{% load staticfiles %}
@ -6,8 +6,14 @@
{% block title %}{{ block.super }} {% trans "User groups" %}{% endblock %}
{% block content %}
<h1>{% trans "User groups" %}</h1>
<table>
<h1>{% trans "User groups" %}
<small class="pull-right">
<a href="{% url user_group_new %}" class="btn btn-mini" rel="tooltip" data-original-title="{% trans 'New user group' %}"><i class="icon-plus"></i> {% trans "New" %}</a>
<a href="{% url user_overview %}" class="btn btn-mini"><i class="icon-chevron-left"></i> {% trans "Participants" %}</a>
</small>
</h1>
<table class="table table-striped table-bordered">
<tr>
<th>{% trans "User Group" %}</th>
<th>{% trans "Actions" %}</th>

View File

@ -1,11 +1,17 @@
{% extends "participant/base_participant.html" %}
{% extends "base.html" %}
{% load i18n %}
{% block title %}{{ block.super }} {% trans "Import participants" %} {% endblock %}
{% block content %}
<h1>{% trans 'Import participants' %}</h1>
<h1>
{% trans 'Import participants' %}
<small class="pull-right">
<a href="{% url user_overview %}" class="btn btn-mini"><i class="icon-chevron-left"></i> {% trans "Back to overview" %}</a>
</small>
</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, comment}</code>' %}
@ -17,15 +23,13 @@
</p>
<form enctype="multipart/form-data" action="" method="post">{% csrf_token %}
{{ form.as_p }}
{% include "form.html" %}
<p>
<button class="button" type="submit">
<button class="btn btn-primary" type="submit">
<span class="icon import">{% trans 'Import' %}</span>
</button>
<a href="{% url user_overview%}">
<button class="button" type="button" onclick="window.location='{% url user_overview %}'">
<span class="icon cancel">{% trans 'Cancel' %}</span>
</button>
<a href="{% url user_overview%}" class="btn">
{% trans 'Cancel' %}
</a>
</p>
<small>* {% trans "required" %}</small>

View File

@ -1,17 +1,8 @@
{% extends "participant/base_participant.html" %}
{% extends "base.html" %}
{% load i18n %}
{% load staticfiles %}
{% block mainmenu %}
<ul>
<li class="selected"><a href="{% url user_login %}" title="">{% trans "Login" %}</a></li>
</ul>
{% endblock %}
{% block submenu %}
{% endblock %}
{% block content %}
<h1>{% trans "Login" %}</h1>

View File

@ -1,4 +1,4 @@
{% extends "participant/base_participant.html" %}
{% extends "base.html" %}
{% load i18n %}
{% load staticfiles %}
@ -7,7 +7,7 @@
{% block title %}{{ block.super }} {% trans "Participants" %}{% endblock %}
{% block header %}
{% if perms.agenda.can_manage_agenda %}
{% if perms.participant.can_manage_participant %}
<link type="text/css" rel="stylesheet" media="all" href="{% static 'styles/participant.css' %}" />
<script type="text/javascript" src="{% static 'javascript/participant.js' %}"></script>
{% endif %}
@ -15,25 +15,59 @@
{% block content %}
<h1>{% trans "Participants" %}</h1>
<h1>{% trans "Participants" %}
<small class="pull-right">
<div class="btn-toolbar">
{% if perms.participant.can_manage_participant %}
<a href="{% url user_new %}" class="btn btn-mini" rel="tooltip" data-original-title="{% trans 'New participant' %}"><i class="icon-plus"></i> {% trans "New" %}</a>
<a href="{% url user_group_overview %}" class="btn btn-mini" rel="tooltip" data-original-title="{% trans 'All user groups' %}"><i class="icon-user"></i> {% trans "User groups" %}</a>
<a href="{% url user_import %}" class="btn btn-mini" rel="tooltip" data-original-title="{% trans 'Import participants' %}"><i class="icon-share-alt"></i> {% trans 'Import' %}</a>
{% endif %}
{% if perms.participant.can_see_participant and perms.participant.can_manage_participant %}
<div class="btn-group pull-right">
{% if user.is_authenticated %}
<a href="#" data-toggle="dropdown" class="btn btn-mini dropdown-toggle">
<i class="icon-print"></i> Print as PDF
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
{% url user_settings as url_usersettings %}
<li><a href="{% url user_print %}"><i class="icon-list"></i> {% trans 'List of participants' %}</a></li>
<li><a href="{% url print_passwords %}"><i class="icon-th-large"></i> {% trans 'First time passwords' %}</a></li>
</ul>
{% else %}
<a href="{% url user_login %}" class="btn">{% trans "Login" %}</a>
{% endif %}
</div>
{% else %}
{% if perms.participant.can_see_participant %}
<a href="{% url user_print %}" class="btn btn-mini" rel="tooltip" data-original-title="{% trans 'Print list of participants as PDF' %}"><i class="icon-print"></i> PDF</a>
{% endif %}
{% if perms.participant.can_manage_participant %}
<a href="{% url print_passwords %}" class="btn btn-mini" rel="tooltip" data-original-title="{% trans 'Print first time passwords as PDF' %}"><i class="icon-print"></i> PDF</a>
{% endif %}
{% endif %}
</div>
</small>
</h1>
<p>
<form action="" name="filter" method="get">
{% trans "Filter" %}:
<select class="default-input" name="gender" onchange="document.forms['filter'].submit()">
<div class="control-group">
<select class="span2" name="gender" onchange="document.forms['filter'].submit()">
<option value="---">-- {% trans "Gender" %} --</option>
<option value="male"{% if 'male' in sortfilter.gender %} selected{% endif %}>{% trans "Male" %}</option>
<option value="female"{% if 'female' in sortfilter.gender %} selected{% endif %}>{% trans "Female" %}</option>
<option value=""{% if '' in sortfilter.gender %} selected{% endif %}>{% trans "Not specified" %}</option>
</select>
<select class="default-input" name="category" onchange="document.forms['filter'].submit()">
<select class="span2" name="category" onchange="document.forms['filter'].submit()">
<option value="---">-- {% trans "Category" %} --</option>
{% for category in categories %}
<option value="{{ category }}"{% if category in sortfilter.category %} selected{% endif %}>
{{ category }}</option>
{% endfor %}
</select>
<select class="default-input" name="type" onchange="document.forms['filter'].submit()">
<select class="span2" name="type" onchange="document.forms['filter'].submit()">
<option value="---">-- {% trans "Type" %} --</option>
<option value="delegate"{% if 'delegate' in sortfilter.type %} selected{% endif %}>{% trans "Delegate" %}</option>
<option value="observer"{% if 'observer' in sortfilter.type %} selected{% endif %}>{% trans "Observer" %}</option>
@ -41,49 +75,51 @@
<option value="guest"{% if 'guest' in sortfilter.type %} selected{% endif %}>{% trans "Guest" %}</option>
<option value=""{% if '' in sortfilter.type %} selected{% endif %}>{% trans "Not specified" %}</option>
</select>
<select class="default-input" name="committee" onchange="document.forms['filter'].submit()">
<select class="span2" name="committee" onchange="document.forms['filter'].submit()">
<option value="---">-- {% trans "Committee" %} --</option>
{% for committee in committees %}
<option value="{{ committee }}"{% if committee in sortfilter.committee %} selected{% endif %}>
{{ committee }}</option>
{% endfor %}
</select>
<select class="default-input" name="status" onchange="document.forms['filter'].submit()">
<select class="span2" name="status" onchange="document.forms['filter'].submit()">
<option value="---">-- {% trans "Status" %} --</option>
<option value="1"{% if '1' in sortfilter.status %} selected{% endif %}>{% trans "Active" %}</option>
<option value="0"{% if '0' in sortfilter.status %} selected{% endif %}>{% trans "Inactive" %}</option>
</select>
</div>
</form>
</p>
<small><i>
{% if users.count == allusers %}
{{ users.count }}
{% blocktrans count counter=users.count %}participant{% plural %}participants{% endblocktrans %}
{% else %}
{{ users.count }} {% trans "of" %} {{ allusers }} {% trans "Participants" %} (= {{ percent }} %)
{% endif %}
</i></small>
<table class="table table-striped table-bordered">
<tr>
<th><a href="?sort=first_name&reverse={% if 'first_name' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{% trans "First Name" %}</a></th>
<th><a href="?sort=last_name&reverse={% if 'last_name' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{% trans "Last Name" %}</a></th>
<th><a href="?sort=group&reverse={% if 'category' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{% trans "Category" %}</a></th>
<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>
<th class="optional"><a href="?sort=group&reverse={% if 'category' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{% trans "Category" %}</a></th>
<th class="optional"><a href="?sort=type&reverse={% if 'type' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{% trans "Type" %}</a></th>
<th class="optional"><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=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>
<th class="optional"><a href="?sort=comment&reverse={% if 'comment' in sortfilter.sort and 'reverse' not in sortfilter %}1{% else %}---{%endif%}">{% trans "Comment" %}</a></th>
<th class="optional"><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 style="width: 1px;">{% trans "Actions" %}</th>
{% endif %}
</tr>
{% for user in users %}
<tr class="{% cycle '' 'odd' %}">
<td>{{ user.first_name }}</td>
<td>{{ user.last_name }}</td>
<td>{{ user.category }}</td>
<td>{{ user.get_type_display }}</td>
<td>{{ user.committee }}</td>
<td class="optional">{{ user.category }}</td>
<td class="optional">{{ user.get_type_display }}</td>
<td class="optional">{{ user.committee }}</td>
{% if perms.participant.can_manage_participant %}
<td>{{ user.comment|first_line }}</td>
<td>
<td class="optional">{{ user.comment|first_line }}</td>
<td class="optional">
{% if user.last_login > user.date_joined %}
{{ user.last_login }}
{% endif %}

View File

@ -4,28 +4,11 @@
{% block title %}{{ block.super }} {% trans "Password Settings" %}{% endblock %}
{% block submenu %}
<h4 class="sectiontitle">{% trans "User Settings" %}</h4>
<ul>
<li><a href="{% url user_settings %}">{% trans "Personal Settings" %}</a></li>
<li class="selected"><a href="{% url password_change %}">{% trans "Password Settings" %}</a></li>
</ul>
{% endblock %}
{% block content %}
<h1>{% trans "Password Settings" %}</h1>
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<button class="button" type="submit">
<span class="icon ok">{% trans 'Save' %}</span>
</button>
<a href=''>
<button class="button" type="button">
<span class="icon cancel">{% trans 'Cancel' %}</span>
</button>
</a>
{% include "form.html" %}
{% include "formbuttons_save.html" %}
</form>
<p></p>
{% endblock %}

View File

@ -4,27 +4,11 @@
{% block title %}{{ block.super }} {% trans "Personal Settings" %}{% endblock %}
{% block submenu %}
<h4 class="sectiontitle">{% trans "User Settings" %}</h4>
<ul>
<li class="selected"><a href="{% url user_settings %}">{% trans "Personal Settings" %}</a></li>
<li><a href="{% url password_change %}">{% trans "Password Settings" %}</a></li>
</ul>
{% endblock %}
{% block content %}
<h1>{% trans "Personal Settings" %}</h1>
<form action="" method="post">{% csrf_token %}
{{ form_user.as_p }}
<button class="button" type="submit">
<span class="icon ok">{% trans 'Save' %}</span>
</button>
<a href=''>
<button class="button" type="button">
<span class="icon cancel">{% trans 'Cancel' %}</span>
</button>
</a>
{% include "form.html" %}
{% include "formbuttons_save.html" %}
</form>
{% endblock %}

View File

@ -451,17 +451,17 @@ def user_settings(request):
Edit own user account.
"""
if request.method == 'POST':
form_user = UsersettingsForm(request.POST, instance=request.user)
if form_user.is_valid():
form_user.save()
form = UsersettingsForm(request.POST, instance=request.user)
if form.is_valid():
form.save()
messages.success(request, _('User settings successfully saved.'))
else:
messages.error(request, _('Please check the form for errors.'))
else:
form_user = UsersettingsForm(instance=request.user)
form = UsersettingsForm(instance=request.user)
return {
'form_user': form_user,
'form': form,
'edituser': request.user,
}

View File

@ -49,10 +49,11 @@ a:hover {
/* show optional column */
.optional {
display: block;
display: auto;
}
.help-inline {
font-size: 11px;
}
/* Left Menu */

View File

@ -42,7 +42,7 @@
<li><a href="{% url user_logout %}"><i class="icon-off"></i> {% trans "Logout" %}</a></li>
</ul>
{% else %}
<a href="{% url user_login %}">{% trans "Login" %}</a>
<a href="{% url user_login %}" class="btn">{% trans "Login" %}</a>
{% endif %}
</div>
</div> <!--/#header-->

View File

@ -0,0 +1,12 @@
{% for field in form %}
<div class="control-group{% if field.errors %} error{% endif%}">
<label for="id_{{ field.name }}">{{ field.label }}{% if field.field.required %}<span class="required">*</span>{% endif %}:</label>
{{ field }}
{% if field.errors %}
<span class="help-inline">{{ field.errors }}</span>
{% endif %}
{% if field.help_text %}
<span class="help-inline">{{ field.help_text }}</span>
{% endif %}
</div>
{% endfor %}

View File

@ -0,0 +1,5 @@
{% load i18n %}
<button class="btn btn-primary" type="submit">
{% trans 'Save' %}
</button>

View File

@ -0,0 +1,8 @@
{% load i18n %}
<button class="btn btn-primary" type="submit">
{% trans 'Save' %}
</button>
<button class="btn" type="submit" name="apply">
{% trans 'Apply' %}
</button>