Adjusted template for assignment app.

This commit is contained in:
Emanuel Schuetze 2012-09-06 23:58:20 +02:00
parent 7c90206b3f
commit ae51d9e7da
3 changed files with 209 additions and 192 deletions

View File

@ -1,4 +1,4 @@
{% extends "assignment/base_assignment.html" %}
{% extends "base.html" %}
{% load i18n %}
@ -11,27 +11,24 @@
{% endif %}
{% endblock %}
{% block content %}
{% if assignment %}
<h1>{% trans "Edit election" %}</h1>
{% else %}
<h1>{% trans "New election" %}</h1>
{% endif %}
<h1>
{% if assignment %}
{% trans "Edit election" %}
{% else %}
{% trans "New election" %}
{% endif %}
<small class="pull-right">
<a href="{% url assignment_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 assignment_overview %}'>
<button class="button" type="button" onclick="window.location='{% url assignment_overview %}'">
<span class="icon cancel">{% trans 'Cancel' %}</span>
</button>
{% include "formbuttons_saveapply.html" %}
<a href='{% url assignment_overview %}' class="btn">
{% trans 'Cancel' %}
</a>
</p>
<small>* {% trans "required" %}</small>

View File

@ -1,30 +1,41 @@
{% extends "assignment/base_assignment.html" %}
{% extends "base.html" %}
{% load i18n %}
{% load staticfiles %}
{% block title %}{{ block.super }} {% trans "Elections" %}{% endblock %}
{% block content %}
<h1>{% trans "Elections" %}</h1>
<p><form action="{{request.url}}" name="filter" method="get">
{% block content %}
<h1>{% trans "Elections" %}
<small class="pull-right">
{% if perms.assignment.can_manage_assignment %}
<a href="{% url assignment_new %}" class="btn btn-mini" rel="tooltip" data-original-title="{% trans 'New election' %}"><i class="icon-plus"></i> {% trans "New" %}</a>
{% endif %}
{% if perms.assignment.can_see_assignment %}
<a href="{% url print_assignment %}" class="btn btn-mini" rel="tooltip" data-original-title="{% trans 'Print all elections as PDF' %}"><i class="icon-print"></i> PDF</a>
{% endif %}
</small>
</h1>
<form action="{{request.url}}" name="filter" method="get">
{% trans "Filter" %}:
<select class="default-input" name="status" onchange="document.forms['filter'].submit()">
<select class="span3" name="status" onchange="document.forms['filter'].submit()">
<option value="---">-- {% trans "Status" %}--</option>
<option value="sea" {% if 'sea' in request.GET.status %}selected{% endif %}>{% trans "Searching for candidates" %}</option>
<option value="vot" {% if 'vot' in request.GET.status %}selected{% endif %}>{% trans "Voting" %}</option>
<option value="fin" {% if 'fin' in request.GET.status %}selected{% endif %}>{% trans "Finished" %}</option>
</select>
</form>
</p>
{{ assignments|length }}
{% blocktrans count counter=assignments|length %}election{% plural %}elections{% endblocktrans %}
</form>
<small><i>{{ assignments|length }}
{% blocktrans count counter=assignments|length %}election{% plural %}elections{% endblocktrans %}
</i></small>
<table class="table table-striped table-bordered">
<tr>
<th><a href="?sort=name{% if 'name' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{% trans "Election" %}</a></th>
<th>{% trans "Candidates" %}</th>
<th><a href="?sort=status{% if 'status' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{% trans "Status" %}</a></th>
<th class="optional"><a href="?sort=status{% if 'status' in request.GET.sort and 'reverse' not in request.GET %}&reverse{%endif%}">{% trans "Status" %}</a></th>
<th style="width: 1px;">{% trans "Actions" %}</th>
</tr>
{% for assignment in assignments %}
@ -32,7 +43,7 @@
{% if assignment.active %}activeline{% endif %}">
<td><a href="{% url assignment_view assignment.id %}">{{ assignment }}</a></td>
<td>{{ assignment.candidates|length }} / {{ assignment.posts }}</td>
<td>{{ assignment.get_status_display }}</td>
<td class="optional">{{ assignment.get_status_display }}</td>
<td>
<span style="width: 1px; white-space: nowrap;">
{% if perms.projector.can_manage_projector %}

View File

@ -1,225 +1,234 @@
{% extends "assignment/base_assignment.html" %}
{% extends "base.html" %}
{% load i18n %}
{% load staticfiles %}
{% block title %}{{ block.super }} {% trans "Election" %} "{{ assignment }}"{% endblock %}
{% block header %}
<link type="text/css" rel="stylesheet" media="all" href="{% static 'styles/assignment.css' %}" />
{% endblock %}
{% block javascript %}
<script type="text/javascript" src="{% static 'javascript/assignment.js' %}"></script>
{% endblock %}
{% block content %}
<div id="sidebar">
<div class="box">
<h4>{% trans "Status" %}:</h4>
{% trans assignment.get_status_display %}
<h4>{% trans "Number of available posts" %}:</h4>
{{ assignment.posts }}
</div>
<h1>{{ assignment }}
<small class="pull-right">
<a href="{% url assignment_overview %}" class="btn btn-mini"><i class="icon-chevron-left"></i> {% trans "Back to overview" %}</a>
</small>
</h1>
<br><br>
{% if perms.assignment.can_manage_assignment %}
<div class="box">
<h4>{% trans "Change status" %}:</h4>
<input type="radio" name="status" onclick="window.location.href='{% url assignment_set_status assignment.id 'sea' %}';"
{% if 'sea' in assignment.status %}checked{% endif %}>{% trans 'Searching for candidates' %}<br>
<input type="radio" name="status" onclick="window.location.href='{% url assignment_set_status assignment.id 'vot' %}';"
{% if 'vot' in assignment.status %}checked{% endif %}>{% trans 'Voting' %}<br>
<input type="radio" name="status" onclick="window.location.href='{% url assignment_set_status assignment.id 'fin' %}';"
{% if 'fin' in assignment.status %}checked{% endif %}>{% trans 'Finished' %}
</div>
<div class="row-fluid">
<div class="span9">
<!-- Description -->
<h4>{% trans "Description" %}</h4>
{% if assignment.description %}
{{ assignment.description|linebreaks }}
{% else %}
{% endif %}
</div>
<div style="margin-right: 250px; min-width: 400px;">
<h1>{{ assignment }}</h1>
<p>{{ assignment.description }}</p>
<h3>{% trans "Candidates" %}</h3>
<br>
<!-- Candidates -->
<h4>{% trans "Candidates" %}</h4>
<ol>
{% for person in assignment.candidates %}
<li>
{{ person }}
{% if perms.assignment.can_manage_assignment %}
{% if assignment.status == "sea" or assignment.status == "vot" %}
<a href="{% url assignment_delother assignment.id person.person_id %}"><img src="{% static 'images/icons/delete.png' %}" title="{% trans 'Remove candidate' %}"></a>
<a href="{% url assignment_delother assignment.id person.person_id %}" class="btn btn-mini" rel="tooltip" data-original-title="{% trans 'Remove candidate' %}"><i class="icon-remove"></i></a>
{% endif %}
{% endif %}
</li>
{% empty %}
<li style="list-style: none outside none;"><i>{% trans "No candidates available." %}</i></li>
<li style="list-style: none outside none; margin-left: -25px;"><i>{% trans "No candidates available." %}</i></li>
{% endfor %}
</ol>
{% if assignment.status == "sea" or perms.assignment.can_manage_assignment and assignment.status == "vot" %}
{% if perms.assignment.can_nominate_self or perms.assignment.can_nominate_other %}
<form action="" method="post">{% csrf_token %}
{% if perms.assignment.can_nominate_self %}
<p>
{% if user_is_candidate %}
<a href='{% url assignment_delrun assignment.id %}'>
<span class="button">
<span class="icon removeuser">{% trans 'Withdraw self candidature' %}</span>
</span>
<a href='{% url assignment_delrun assignment.id %}' class="btn">
<i class="icon-remove"></i> {% trans 'Withdraw self candidature' %}
</a>
{% else %}
<a href='{% url assignment_run assignment.id %}'>
<span class="button">
<span class="icon adduser">{% trans 'Self candidature' %}</span>
</span>
<a href='{% url assignment_run assignment.id %}' class="btn">
<i class="icon-plus"></i> {% trans 'Self candidature' %}
</a>
{% endif %}
</p>
{% endif %}
{% if perms.assignment.can_nominate_other %}
{% for field in form %}
<label>{{ field.label }}:</label>
<nobr>{{ field }}
{% if perms.participant.can_see_participant and perms.participant.can_manage_participant %}
<a href="{% url user_new %}" target="_blank"><img src="{% static 'images/icons/add-user.png' %}" title="{% trans 'Add new participant' %}"></a>
{% endif %}
</nobr>
<label>{{ field.label }}:</label>
<nobr>{{ field }}
{% if perms.participant.can_see_participant and perms.participant.can_manage_participant %}
<a href="{% url user_new %}" target="_blank"><img src="{% static 'images/icons/add-user.png' %}" title="{% trans 'Add new participant' %}"></a>
{% endif %}
</nobr>
{% endfor %}
<p>
<button class="button" type="submit">
<span class="icon ok">{% trans 'Apply' %}</span>
<button class="btn" type="submit">
{% trans 'Apply' %}
</button>
</p>
{% endif %}
</form>
{% endif %}
{% endif %}
<p><br></p>
<h3>{% trans "Election results" %}</h3>
{% if polls.exists %}
<table id="election_table" style="width: auto;">
<tr>
<th></th>
{% with ballotnumber=polls.count %}
<th colspan="{{ ballotnumber|add:'1' }}" style="text-align: center;">
{% trans "ballot" %}
</th>
{% endwith %}
</tr>
<tr>
<th>{% trans "Candidates" %}</th>
{% for poll in polls %}
<th style="vertical-align: top; white-space:nowrap;">
{{ poll.get_ballot }}. {% trans 'ballot' %}
{% if perms.assignment.can_manage_assignment %}
<br>
<a class="publish_link {% if poll.published %}published{% endif %}"
href="{% url assignment_poll_publish_status poll.id %}"
title="{% trans 'Publish/unpublish results' %}">
<span></span>
</a>
<a href="{% url assignment_poll_view poll.id %}"><img src="{% static 'images/icons/edit.png' %}" title="{% trans 'Edit' %}"></a>
<a href="{% url assignment_poll_delete poll.id %}"><img src="{% static 'images/icons/delete.png' %}" title="{% trans 'Delete' %}"></a>
{% endif %}
<!-- Results -->
<h4>{% trans "Election results" %}</h4>
{% if polls.exists %}
<table class="table table-striped table-bordered">
<tr>
<th></th>
{% with ballotnumber=polls.count %}
<th colspan="{{ ballotnumber|add:'1' }}" style="text-align: center;">
{% trans "ballot" %}
</th>
{% endfor %}
{% if assignment.candidates and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<th>
<a href='{% url assignment_gen_poll assignment.id %}'>
<span class="button">
<span class="icon statistics">{% trans 'New ballot' %}</span>
</span>
</a>
</th>
{% endif %}
</tr>
{% for candidate, poll_list in vote_results.items %}
<tr class="{% cycle 'odd' '' %}">
<td class="candidate">
{% if candidate in assignment.elected %}
{% if perms.assignment.can_manage_assignment %}
<a class="election_link elected" href='{% url assignment_user_not_elected assignment.id candidate.person_id %}'></a>
{% else %}
<a class="elected">
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Candidate is elected' %}">
{% endwith %}
</tr>
<tr>
<th>{% trans "Candidates" %}</th>
{% for poll in polls %}
<th style="white-space:nowrap;" class="span1">
{{ poll.get_ballot }}. {% trans 'ballot' %}
{% if perms.assignment.can_manage_assignment %}
<br>
<a class="publish_link {% if poll.published %}published{% endif %}"
href="{% url assignment_poll_publish_status poll.id %}"
title="{% trans 'Publish/unpublish results' %}">
<span></span>
</a>
<a href="{% url assignment_poll_view poll.id %}" class="btn btn-mini" title="{% trans 'Edit' %}"><i class="icon-pencil"></i></a>
<a href="{% url assignment_poll_delete poll.id %}" class="btn btn-mini" title="{% trans 'Delete' %}"><i class="icon-remove"></i></a>
{% endif %}
</th>
{% endfor %}
{% if assignment.candidates and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<th class="span1 nobr">
<a href='{% url assignment_gen_poll assignment.id %}' class="btn">
<i class="icon-plus"></i> {% trans 'New ballot' %}
</a>
{% endif %}
{% else %}
{% if perms.assignment.can_manage_assignment %}
<a class="election_link" href='{% url assignment_user_elected assignment.id candidate.person_id %}'></a>
{% endif %}
</th>
{% endif %}
{{ candidate }}
</td>
{% for vote in poll_list %}
<td style="white-space:nowrap;">
{% if 'Yes' in vote and 'No' in vote and 'Abstain' in vote %}
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Yes' %}"> {{ vote.Yes }}<br>
<img src="{% static 'images/icons/voting-no.png' %}" title="{% trans 'No' %}"> {{ vote.No }}<br>
<img src="{% static 'images/icons/voting-abstention.png' %}" title="{% trans 'Abstention' %}"> {{ vote.Abstain }}<br>
{% elif 'Votes' in vote %}
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Yes' %}"> {{ vote.Votes }}
{% elif vote == None %}
{% trans 'was not a <br> candidate'%}
</tr>
{% for candidate, poll_list in vote_results.items %}
<tr>
<td>
{% if candidate in assignment.elected %}
{% if perms.assignment.can_manage_assignment %}
<a class="election_link elected" href='{% url assignment_user_not_elected assignment.id candidate.person_id %}'></a>
{% else %}
<a class="elected">
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Candidate is elected' %}">
</a>
{% endif %}
{% else %}
&nbsp;
{% if perms.assignment.can_manage_assignment %}
<a class="election_link" href='{% url assignment_user_elected assignment.id candidate.person_id %}'></a>
{% endif %}
{% endif %}
{{ candidate }}
</td>
{% endfor %}
{% if assignment.candidates and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<td></td>
{% endif %}
</tr>
{% endfor %}
<tr>
<td>{% trans 'Invalid votes' %}</td>
{% for poll in polls %}
{% if poll.published or perms.assignment.can_manage_assignment %}
{% for vote in poll_list %}
<td style="white-space:nowrap;">
{% if poll.has_votes %}
<img src="{% static 'images/icons/voting-invalid.png' %}" title="{% trans 'Invalid' %}">
{{ poll.print_votesinvalid }}
{% if 'Yes' in vote and 'No' in vote and 'Abstain' in vote %}
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Yes' %}"> {{ vote.Yes }}<br>
<img src="{% static 'images/icons/voting-no.png' %}" title="{% trans 'No' %}"> {{ vote.No }}<br>
<img src="{% static 'images/icons/voting-abstention.png' %}" title="{% trans 'Abstention' %}"> {{ vote.Abstain }}<br>
{% elif 'Votes' in vote %}
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Yes' %}"> {{ vote.Votes }}
{% elif vote == None %}
{% trans 'was not a <br> candidate'%}
{% else %}
&nbsp;
{% endif %}
</td>
{% endfor %}
{% if assignment.candidates and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<td></td>
{% endif %}
</tr>
{% endfor %}
{% if assignment.candidates and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<td></td>
{% endif %}
</tr>
<tr class="total">
<td><strong>{% trans 'Votes cast' %}</strong></td>
{% for poll in polls %}
{% if poll.published or perms.assignment.can_manage_assignment %}
<td style="white-space:nowrap;">
{% if poll.has_votes %}
<img src="{% static 'images/icons/voting-total.png' %}" title="{% trans 'Votes cast' %}">
<strong>{{ poll.print_votescast }}</strong>
{% endif %}
</td>
<tr>
<td>{% trans 'Invalid votes' %}</td>
{% for poll in polls %}
{% if poll.published or perms.assignment.can_manage_assignment %}
<td style="white-space:nowrap;">
{% if poll.has_votes %}
<img src="{% static 'images/icons/voting-invalid.png' %}" title="{% trans 'Invalid' %}">
{{ poll.print_votesinvalid }}
{% endif %}
</td>
{% endif %}
{% endfor %}
{% if assignment.candidates and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<td></td>
{% endif %}
{% endfor %}
</tr>
<tr class="info total">
<td><strong>{% trans 'Votes cast' %}</strong></td>
{% for poll in polls %}
{% if poll.published or perms.assignment.can_manage_assignment %}
<td style="white-space:nowrap;">
{% if poll.has_votes %}
<img src="{% static 'images/icons/voting-total.png' %}" title="{% trans 'Votes cast' %}">
<strong>{{ poll.print_votescast }}</strong>
{% endif %}
</td>
{% endif %}
{% endfor %}
{% if assignment.candidates and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<td></td>
{% endif %}
</tr>
</table>
{% else %}
<i>{% trans "No ballots available." %}</i>
{% if assignment.candidates and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<td></td>
<p>
<a href='{% url assignment_gen_poll assignment.id %}' class="btn">
<i class="icon-plus"></i> {% trans 'New ballot' %}
</a>
</p>
{% endif %}
</tr>
</table>
{% else %}
<i>{% trans "No ballots available." %}</i>
{% if assignment.candidates and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
<p><a href='{% url assignment_gen_poll assignment.id %}'>
<span class="button">
<span class="icon statistics">{% trans 'New ballot' %}</span>
</span>
</a></p>
{% endif %}
</div> <!--/span-->
{% endif %}
</div>
<div class="span3">
<div class="well">
<!-- Text -->
<h5>{% trans "Status" %}:</h5>
{% trans assignment.get_status_display %}
<!-- Posts -->
<h5>{% trans "Number of available posts" %}:</h5>
{{ assignment.posts }}
</div> <!--/well-->
{% if perms.assignment.can_manage_assignment %}
<div class="well">
<h4>{% trans "Change status" %}:</h4>
<label class="radio">
<input type="radio" name="status" onclick="window.location.href='{% url assignment_set_status assignment.id 'sea' %}';"
{% if 'sea' in assignment.status %}checked{% endif %}>{% trans 'Searching for candidates' %}
</label>
<label class="radio">
<input type="radio" name="status" onclick="window.location.href='{% url assignment_set_status assignment.id 'vot' %}';"
{% if 'vot' in assignment.status %}checked{% endif %}>{% trans 'Voting' %}<br>
</label>
<label class="radio">
<input type="radio" name="status" onclick="window.location.href='{% url assignment_set_status assignment.id 'fin' %}';"
{% if 'fin' in assignment.status %}checked{% endif %}>{% trans 'Finished' %}
</label>
</div> <!--/well-->
{% endif %}
</div> <!--/span-->
</div> <!--/row-->
{% endblock %}