#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 %} {% block content %}
<div id="sidebar"> <div id="sidebar">
<div class="box"> <div class="box">
<h4>{% trans "Status" %}:</h4> <h4>{% trans "Status" %}:</h4>
{% trans assignment.get_status_display %} {% trans assignment.get_status_display %}
<h4>{% trans "Number of available posts" %}:</h4> <h4>{% trans "Number of available posts" %}:</h4>
{{ assignment.posts }} {{ assignment.posts }}
</div> </div>
<br><br> <br><br>
{% if perms.assignment.can_manage_assignment %} {% if perms.assignment.can_manage_assignment %}
<div class="box"> <div class="box">
<h4>{% trans "Change status" %}:</h4> <h4>{% trans "Change status" %}:</h4>
<input type="radio" name="status" onclick="window.location.href='{% url assignment_set_status assignment.id 'sea' %}';" <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> {% 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' %}';" <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> {% 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' %}';" <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' %} {% if 'fin' in assignment.status %}checked{% endif %}>{% trans 'Finish' %}
</div> </div>
{% endif %} {% endif %}
</div> </div>
<div style="margin-right: 250px; min-width: 400px;"> <div style="margin-right: 250px; min-width: 400px;">
@ -180,7 +177,12 @@
<td>{% trans 'Invalid votes' %}</td> <td>{% trans 'Invalid votes' %}</td>
{% for poll in polls %} {% for poll in polls %}
{% if poll.published or perms.assignment.can_manage_assignment %} {% 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 %} {% endif %}
{% endfor %} {% endfor %}
{% if assignment.profile.exists and perms.assignment.can_manage_assignment and assignment.status == "vot" %} {% 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> <td><strong>{% trans 'Votes cast' %}</strong></td>
{% for poll in polls %} {% for poll in polls %}
{% if poll.published or perms.assignment.can_manage_assignment %} {% 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 %} {% endif %}
{% endfor %} {% endfor %}
{% if assignment.profile.exists and perms.assignment.can_manage_assignment and assignment.status == "vot" %} {% if assignment.profile.exists and perms.assignment.can_manage_assignment and assignment.status == "vot" %}

View File

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

View File

@ -175,7 +175,7 @@ class BasePoll(models.Model):
""" """
Return a QuerySet with all vote objects, releatet to this poll. 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): def set_form_values(self, option, data):
# TODO: recall this function. It has nothing to do with a form # TODO: recall this function. It has nothing to do with a form