Added apply buttons. Some style changes. Fix permissions.
This commit is contained in:
parent
7c866e11e4
commit
021fb27833
@ -27,7 +27,7 @@
|
||||
<span class="icon ok">{%trans 'Save' %}</span>
|
||||
</button>
|
||||
<button type="submit" name="apply">
|
||||
<span class="icon ok">{%trans 'Apply' %}</span>
|
||||
<span class="icon apply">{%trans 'Apply' %}</span>
|
||||
</button>
|
||||
<a href='{% url item_overview %}'>
|
||||
<button type="button">
|
||||
|
@ -70,7 +70,7 @@
|
||||
{% if perms.agenda.can_manage_agenda %}
|
||||
<td></td>
|
||||
{% endif %}
|
||||
<td style="width: 1px;white-space: nowrap"><a href="{% url print_agenda %}" title="{%trans 'Print agenda' %}"><img src="/static/images/icons/application-pdf.png"></a></td>
|
||||
<td style="width: 1px;white-space: nowrap;"><a href="{% url print_agenda %}" title="{%trans 'Print agenda' %}"><img src="/static/images/icons/application-pdf.png"></a></td>
|
||||
</tr>
|
||||
{% for item in items %}
|
||||
{% if not item.hidden or perms.agenda.can_manage_agenda %}
|
||||
@ -124,7 +124,7 @@
|
||||
{% endifequal %}
|
||||
</td>
|
||||
{% endif %}
|
||||
<td style="width: 1px;white-space: nowrap">
|
||||
<td style="width: 1px;white-space: nowrap;">
|
||||
<a href="{{ item.get_absolute_url }}"><img src="/static/images/icons/document-preview.png" title="{% trans 'Show beamer preview' %}"></a>
|
||||
|
||||
{% if perms.agenda.can_manage_agenda %}
|
||||
|
@ -346,7 +346,7 @@ class Application(models.Model):
|
||||
raise AttributeError(name)
|
||||
raise AttributeError(name)
|
||||
|
||||
def gen_poll(self, user=None, pollcount=None):
|
||||
def gen_poll(self, user=None):
|
||||
"""
|
||||
Generates a poll object for the application
|
||||
"""
|
||||
|
@ -16,6 +16,9 @@
|
||||
<button type="submit">
|
||||
<span class="icon ok">{%trans 'Save' %}</span>
|
||||
</button>
|
||||
<button type="submit" name="apply">
|
||||
<span class="icon apply">{%trans 'Apply' %}</span>
|
||||
</button>
|
||||
<a href='{% url application_overview %}'>
|
||||
<button type="button">
|
||||
<span class="icon cancel">{%trans 'Cancel' %}</span>
|
||||
|
@ -14,40 +14,49 @@
|
||||
|
||||
{% block content %}
|
||||
<h1>{%trans "Application" %} #{{ poll.application.number }} - {%trans "Vote" %}</h1>
|
||||
<h4>{{ poll.application.title }}</h4>
|
||||
<h3>{{ poll.application.title }}</h3>
|
||||
|
||||
<p>{%trans "Results of" %} {{ ballot }}. {%trans "Vote" %}</p>
|
||||
|
||||
{% if perms.poll.can_manage_poll %}
|
||||
<form action="" method="post">{% csrf_token %}
|
||||
<fieldset>
|
||||
<legend>{%trans "Results" %}: {{ ballot }}. {%trans "Vote" %}</legend>
|
||||
<p><nobr><label>{%trans "Votes in favour" %}:</label></nobr>
|
||||
{{ options.0.form.yes.errors }}{{ options.0.form.yes }}
|
||||
</p>
|
||||
<p><nobr><label>{%trans "Votes against" %}:</label></nobr>
|
||||
{{ options.0.form.no.errors }}{{ options.0.form.no }}
|
||||
</p>
|
||||
<p><nobr><label>{%trans "Abstentions" %}:</label></nobr>
|
||||
{{ options.0.form.undesided.errors }}{{ options.0.form.undesided }}
|
||||
</p>
|
||||
<p><label>{%trans "Invalid votes" %}:</label>
|
||||
{{ form.invalid.errors }}{{ form.invalid }}
|
||||
</p>
|
||||
<p><label>{%trans "Votes cast" %}:</label>
|
||||
{{ form.votescast.errors }}{{ form.votescast }}
|
||||
</p>
|
||||
<table class="table" style="width: auto;">
|
||||
<tr>
|
||||
<th>{%trans "Option" %}</th>
|
||||
<th>{%trans "Votes" %}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{%trans "Yes" %}</td>
|
||||
<td>{{ options.0.form.yes.errors }}{{ options.0.form.yes }}</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td>{%trans "No" %}</label></td>
|
||||
<td>{{ options.0.form.no.errors }}{{ options.0.form.no }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{%trans "Abstentions" %}</td>
|
||||
<td>{{ options.0.form.undesided.errors }}{{ options.0.form.undesided }}</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td>{%trans "Invalid votes" %}</td>
|
||||
<td>{{ form.invalid.errors }}{{ form.invalid }}</td>
|
||||
</tr>
|
||||
<tr class="total">
|
||||
<td style="white-space: nowrap;"><b>{%trans "Votes cast" %}</b></td>
|
||||
<td>{{ form.votescast.errors }}{{ form.votescast }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
<button type="submit">
|
||||
<span class="icon ok">{%trans 'Apply' %}</span>
|
||||
<span class="icon ok">{%trans 'Save' %}</span>
|
||||
</button>
|
||||
<button type="submit" name="apply">
|
||||
<span class="icon apply">{%trans 'Apply' %}</span>
|
||||
</button>
|
||||
</fieldset>
|
||||
|
||||
<p></p>
|
||||
<a href='{% url application_view poll.application.id %}'>
|
||||
<button type="button">
|
||||
<span class="icon previous">{%trans 'Back to application' %}</span>
|
||||
<span class="icon cancel">{%trans 'Cancel' %}</span>
|
||||
</button>
|
||||
</a>
|
||||
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
@ -287,12 +287,11 @@ def gen_poll(request, application_id):
|
||||
gen a poll for this application.
|
||||
"""
|
||||
try:
|
||||
count = Poll.objects.filter(application=application_id).count()
|
||||
Application.objects.get(pk=application_id).gen_poll(user=request.user, pollcount=count+1)
|
||||
messages.success(request, _("New poll was successfully created.") )
|
||||
poll = Application.objects.get(pk=application_id).gen_poll(user=request.user)
|
||||
messages.success(request, _("New vote was successfully created.") )
|
||||
except Application.DoesNotExist:
|
||||
pass
|
||||
return redirect(reverse('application_view', args=[application_id]))
|
||||
return redirect(reverse('application_poll_view', args=[poll.id]))
|
||||
|
||||
|
||||
@permission_required('application.can_manage_application')
|
||||
@ -311,7 +310,7 @@ def delete_poll(request, poll_id):
|
||||
return redirect(reverse('application_view', args=[application.id]))
|
||||
|
||||
|
||||
@permission_required('application.can_view_poll')
|
||||
@permission_required('application.can_manage_application')
|
||||
@template('application/poll_view.html')
|
||||
def view_poll(request, poll_id):
|
||||
"""
|
||||
@ -320,7 +319,7 @@ def view_poll(request, poll_id):
|
||||
poll = Poll.objects.get(pk=poll_id)
|
||||
ballot = poll.ballot
|
||||
options = poll.options
|
||||
if request.user.has_perm('application.can_manage_applications'):
|
||||
if request.user.has_perm('application.can_manage_application'):
|
||||
if request.method == 'POST':
|
||||
form = PollForm(request.POST, prefix="poll")
|
||||
if form.is_valid():
|
||||
@ -337,6 +336,9 @@ def view_poll(request, poll_id):
|
||||
option.voteundesided = option.form. \
|
||||
cleaned_data['undesided'] or 0
|
||||
option.save()
|
||||
messages.success(request, _("Votes are successfully saved.") )
|
||||
if not 'apply' in request.POST:
|
||||
return redirect(reverse('application_view', args=[poll.application.id]))
|
||||
else:
|
||||
form = PollForm(initial={'invalid': poll.votesinvalid, 'votescast': poll.votescast}, prefix="poll")
|
||||
for option in options:
|
||||
|
@ -14,6 +14,9 @@
|
||||
<button type="submit">
|
||||
<span class="icon ok">{%trans 'Save' %}</span>
|
||||
</button>
|
||||
<button type="submit" name="apply">
|
||||
<span class="icon apply">{%trans 'Apply' %}</span>
|
||||
</button>
|
||||
<a href='{% url assignment_overview %}'>
|
||||
<button type="button">
|
||||
<span class="icon cancel">{%trans 'Cancel' %}</span>
|
||||
|
@ -8,7 +8,7 @@
|
||||
</p>
|
||||
<p><b>{% trans "Short description" %}:</b> {{ poll.description }}</p>
|
||||
<form action="" method="post">{% csrf_token %}
|
||||
<table class="table">
|
||||
<table class="table" style="width:auto;">
|
||||
<tr>
|
||||
<th>{%trans "Option" %}</th>
|
||||
{% if poll.optiondecision %}
|
||||
@ -20,7 +20,7 @@
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% for option in options %}
|
||||
<tr>
|
||||
<tr class="{% cycle 'odd' '' %}">
|
||||
<td>{{ option }}</td>
|
||||
{% if poll.optiondecision %}
|
||||
<td>{{ option.form.yes.errors }}{{ option.form.yes }}</td>
|
||||
@ -31,31 +31,38 @@
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr class="total">
|
||||
<td>{% trans "Invalid votes" %}</td>
|
||||
<td {% if poll.optiondecision %}colspan="3"{% endif %}>{{ form.invalid.errors }}{{ form.invalid }}</td>
|
||||
</tr>
|
||||
<tr class="total">
|
||||
<td style="white-space: nowrap;"><b>{% trans "Votes cast" %}</b></td>
|
||||
<td {% if poll.optiondecision %}colspan="3"{% endif %}>{{ form.votescast.errors }}{{ form.votescast }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<label for="id_votesinvalid">{% trans "Invalid votes" %}:</label>
|
||||
{{ form.invalid.errors }}{{ form.invalid }}
|
||||
|
||||
<label for="id_votescast">{% trans "Votes cast" %}:</label>
|
||||
{{ form.votescast.errors }}{{ form.votescast }}
|
||||
|
||||
{% if perms.poll.can_manage_poll %}
|
||||
<p>
|
||||
<button type="submit">
|
||||
<span class="icon ok">{%trans 'Apply' %}</span>
|
||||
</button>
|
||||
<a href='{% url assignment_view poll.assignment.id %}'>
|
||||
<button type="button">
|
||||
<span class="icon previous">{%trans 'Back to election' %}</span>
|
||||
</button>
|
||||
</a>
|
||||
<a href='{% url print_assignment_poll poll.id %}'>
|
||||
<button type="button">
|
||||
<span class="icon pdf">{%trans 'Print ballot' %}</span>
|
||||
</button>
|
||||
</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<p>
|
||||
<button type="submit">
|
||||
<span class="icon ok">{%trans 'Save' %}</span>
|
||||
</button>
|
||||
<button type="submit" name="apply">
|
||||
<span class="icon apply">{%trans 'Apply' %}</span>
|
||||
</button>
|
||||
<a href='{% url assignment_view poll.assignment.id %}'>
|
||||
<button type="button">
|
||||
<span class="icon cancel">{%trans 'Cancel' %}</span>
|
||||
</button>
|
||||
</a>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
|
@ -108,6 +108,7 @@ def edit(request, assignment_id=None):
|
||||
messages.success(request, _('New election was successfully created.'))
|
||||
else:
|
||||
messages.success(request, _('Election was successfully modified.'))
|
||||
if not 'apply' in request.POST:
|
||||
return redirect(reverse("assignment_overview"))
|
||||
else:
|
||||
form = AssignmentForm(instance=assignment)
|
||||
@ -188,7 +189,7 @@ def gen_poll(request, assignment_id):
|
||||
return redirect(reverse('assignment_poll_view', args=[poll.id]))
|
||||
|
||||
|
||||
@permission_required('assignment.can_view_assignment')
|
||||
@permission_required('assignment.can_manage_assignment')
|
||||
@template('assignment/poll_view.html')
|
||||
def poll_view(request, poll_id):
|
||||
poll = Poll.objects.get(pk=poll_id)
|
||||
@ -214,6 +215,8 @@ def poll_view(request, poll_id):
|
||||
success = success + 1
|
||||
if success == options.count():
|
||||
messages.success(request, _("Votes are successfully saved.") )
|
||||
if not 'apply' in request.POST:
|
||||
return redirect(reverse('assignment_view', args=[assignment.id]))
|
||||
else:
|
||||
form = PollForm(initial={'invalid': poll.votesinvalid, 'votescast': poll.votescast}, prefix="poll")
|
||||
for option in options:
|
||||
|
@ -252,6 +252,7 @@ table a.table_edit {
|
||||
}
|
||||
tr.total td {
|
||||
border-top: 1px solid #333333;
|
||||
background-color: #e3e3e3;
|
||||
}
|
||||
|
||||
|
||||
@ -411,7 +412,7 @@ button .stop{
|
||||
|
||||
.errorlist {
|
||||
color:#DA3939;
|
||||
font-size:10px;
|
||||
font-size:9px;
|
||||
font-style:italic;
|
||||
height:16px;
|
||||
padding:0;
|
||||
|
@ -15,10 +15,6 @@
|
||||
<li>
|
||||
<a href="{% url assignment_overview %}" title="">{%trans "Elections" %}</a></li>
|
||||
{% endif %}
|
||||
{% if perms.poll.can_view_poll or perms.poll.can_manage_poll %}
|
||||
<li>
|
||||
<a href="{% url poll_overview %}" title="">{%trans "Polls" %}</a></li>
|
||||
{% endif %}
|
||||
{% if perms.participant.can_view_participants or perms.participant.can_manage_participants %}
|
||||
<li>
|
||||
<a href="{% url user_overview %}" title="">{%trans "Participants" %}</a></li>
|
||||
|
@ -15,10 +15,6 @@
|
||||
<li>
|
||||
<a href="{% url assignment_overview %}" title="">{%trans "Elections" %}</a></li>
|
||||
{% endif %}
|
||||
{% if perms.poll.can_view_poll or perms.poll.can_manage_poll %}
|
||||
<li>
|
||||
<a href="{% url poll_overview %}" title="">{%trans "Polls" %}</a></li>
|
||||
{% endif %}
|
||||
{% if perms.participant.can_view_participants or perms.participant.can_manage_participants %}
|
||||
<li>
|
||||
<a href="{% url user_overview %}" title="">{%trans "Participants" %}</a></li>
|
||||
|
@ -15,10 +15,6 @@
|
||||
<li>
|
||||
<a href="{% url assignment_overview %}" title="">{%trans "Elections" %}</a></li>
|
||||
{% endif %}
|
||||
{% if perms.poll.can_view_poll or perms.poll.can_manage_poll %}
|
||||
<li>
|
||||
<a href="{% url poll_overview %}" title="">{%trans "Polls" %}</a></li>
|
||||
{% endif %}
|
||||
{% if perms.participant.can_view_participants or perms.participant.can_manage_participants %}
|
||||
<li>
|
||||
<a href="{% url user_overview %}" title="">{%trans "Participants" %}</a></li>
|
||||
|
Loading…
Reference in New Issue
Block a user