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 %} {% load i18n %}
@ -11,27 +11,24 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% if assignment %} <h1>
<h1>{% trans "Edit election" %}</h1> {% if assignment %}
{% else %} {% trans "Edit election" %}
<h1>{% trans "New election" %}</h1> {% else %}
{% endif %} {% 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 action="" method="post">{% csrf_token %}
{{ form.as_p }} {% include "form.html" %}
<p> <p>
<button class="button" type="submit"> {% include "formbuttons_saveapply.html" %}
<span class="icon ok">{% trans 'Save' %}</span> <a href='{% url assignment_overview %}' class="btn">
</button> {% trans 'Cancel' %}
<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>
</a> </a>
</p> </p>
<small>* {% trans "required" %}</small> <small>* {% trans "required" %}</small>

View File

@ -1,30 +1,41 @@
{% extends "assignment/base_assignment.html" %} {% extends "base.html" %}
{% load i18n %} {% load i18n %}
{% load staticfiles %} {% load staticfiles %}
{% block title %}{{ block.super }} {% trans "Elections" %}{% endblock %} {% 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" %}: {% 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="---">-- {% trans "Status" %}--</option>
<option value="sea" {% if 'sea' in request.GET.status %}selected{% endif %}>{% trans "Searching for candidates" %}</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="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> <option value="fin" {% if 'fin' in request.GET.status %}selected{% endif %}>{% trans "Finished" %}</option>
</select> </select>
</form> </form>
</p>
{{ assignments|length }} <small><i>{{ assignments|length }}
{% blocktrans count counter=assignments|length %}election{% plural %}elections{% endblocktrans %} {% blocktrans count counter=assignments|length %}election{% plural %}elections{% endblocktrans %}
</i></small>
<table class="table table-striped table-bordered"> <table class="table table-striped table-bordered">
<tr> <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><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>{% 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> <th style="width: 1px;">{% trans "Actions" %}</th>
</tr> </tr>
{% for assignment in assignments %} {% for assignment in assignments %}
@ -32,7 +43,7 @@
{% if assignment.active %}activeline{% endif %}"> {% if assignment.active %}activeline{% endif %}">
<td><a href="{% url assignment_view assignment.id %}">{{ assignment }}</a></td> <td><a href="{% url assignment_view assignment.id %}">{{ assignment }}</a></td>
<td>{{ assignment.candidates|length }} / {{ assignment.posts }}</td> <td>{{ assignment.candidates|length }} / {{ assignment.posts }}</td>
<td>{{ assignment.get_status_display }}</td> <td class="optional">{{ assignment.get_status_display }}</td>
<td> <td>
<span style="width: 1px; white-space: nowrap;"> <span style="width: 1px; white-space: nowrap;">
{% if perms.projector.can_manage_projector %} {% if perms.projector.can_manage_projector %}

View File

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