#300 dont show votecast and voteinvalid symbols, if the vote has no votes

This commit is contained in:
Oskar Hahn 2012-07-16 14:29:30 +02:00
parent 4e5884bda4
commit 76e52cf01a
3 changed files with 46 additions and 27 deletions

View File

@ -7,29 +7,26 @@
{% 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 }}
<h4>{% trans "Status" %}:</h4>
{% trans assignment.get_status_display %}
<h4>{% trans "Number of available posts" %}:</h4>
{{ assignment.posts }}
</div>
<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 'Finish' %}
</div>
<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 'Finish' %}
</div>
{% endif %}
</div>
<div style="margin-right: 250px; min-width: 400px;">
@ -180,7 +177,12 @@
<td>{% trans 'Invalid votes' %}</td>
{% for poll in polls %}
{% if poll.published or perms.assignment.can_manage_assignment %}
<td style="white-space:nowrap;"><img src="{% static 'images/icons/voting-invalid.png' %}" title="{% trans 'Invalid' %}"> {{ poll.print_votesinvalid }}</td>
<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.profile.exists and perms.assignment.can_manage_assignment and assignment.status == "vot" %}
@ -192,7 +194,12 @@
<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;"><img src="{% static 'images/icons/voting-total.png' %}" title="{% trans 'Votes cast' %}"> <strong>{{ poll.print_votescast }}</strong></td>
<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.profile.exists and perms.assignment.can_manage_assignment and assignment.status == "vot" %}

View File

@ -55,7 +55,9 @@
<tr>
<th>{% trans "Candidates" %}</th>
{% for poll in polls %}
<th><nobr>{{ poll.get_ballot }}. {% trans "ballot" %}</nobr></th>
<th>
<nobr>{{ poll.get_ballot }}. {% trans "ballot" %}</nobr>
</th>
{% endfor %}
</tr>
@ -94,18 +96,28 @@
<tr>
<td>{% trans 'Invalid votes' %}</td>
{% for poll in polls %}
{% if poll.published %}
<td style="white-space:nowrap;"><img src="{% static 'images/icons/voting-invalid.png' %}" title="{% trans 'Invalid' %}"> {{ poll.print_votesinvalid }}</td>
{% endif %}
<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>
{% endfor %}
</tr>
<tr class="total">
<td><b>{% trans 'Votes cast' %}</b></td>
<td>
<strong>{% trans 'Votes cast' %}</strong>
</td>
{% for poll in polls %}
{% if poll.published %}
<td style="white-space:nowrap;"><img src="{% static 'images/icons/voting-total.png' %}" title="{% trans 'Votes cast' %}"> <b>{{ poll.print_votescast }}</b></td>
{% endif %}
<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>
{% endfor %}
</tr>

View File

@ -175,7 +175,7 @@ class BasePoll(models.Model):
"""
Return a QuerySet with all vote objects, releatet to this poll.
"""
return self.get_vote_class().objects
return self.get_vote_class().objects.filter(option__poll__id=self.id)
def set_form_values(self, option, data):
# TODO: recall this function. It has nothing to do with a form