#253 don't show unpublished polls for nonmanager in assignment view

This commit is contained in:
Oskar Hahn 2012-07-04 16:05:31 +02:00
parent 47ff052c22
commit ef5b9e3281
2 changed files with 35 additions and 28 deletions

View File

@ -128,16 +128,19 @@ class Assignment(models.Model, SlideMixin):
continue continue
vote_results_dict[candidate] = [] vote_results_dict[candidate] = []
for poll in polls: for poll in polls:
votes = {
'votes': {},
'published': poll.published,
}
try: try:
polloption = poll.get_options().get(candidate=candidate) # candidate related to this poll
# candidate is related to this poll poll_option = poll.get_options().get(candidate=candidate)
votes = {} for vote in poll_option.get_votes():
for vote in polloption.get_votes(): votes['votes'][vote.value] = vote.get_weight()
votes[vote.value] = vote.get_weight()
vote_results_dict[candidate].append(votes)
except AssignmentOption.DoesNotExist: except AssignmentOption.DoesNotExist:
# candidate not in related to this poll # candidate not in related to this poll
vote_results_dict[candidate].append(None) votes['votes'] = None
vote_results_dict[candidate].append(votes)
return vote_results_dict return vote_results_dict

View File

@ -139,14 +139,17 @@
{% endif %} {% endif %}
</tr> </tr>
{% for candidate, votes in vote_results.items %} {% for candidate, poll_list in vote_results.items %}
<tr class="{% cycle 'odd' '' %}"> <tr class="{% cycle 'odd' '' %}">
<td class="candidate"> <td class="candidate">
{% if candidate in assignment.elected.all %} {% if candidate in assignment.elected.all %}
{% if perms.assignment.can_manage_assignment %} {% if perms.assignment.can_manage_assignment %}
{# What does this line do #}
<a class="election_link elected" href='{% url assignment_user_not_elected assignment.id candidate.id %}'></a> <a class="election_link elected" href='{% url assignment_user_not_elected assignment.id candidate.id %}'></a>
{% else %} {% else %}
<a class="elected"><img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Candidate is elected' %}"></a> <a class="elected">
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Candidate is elected' %}">
</a>
{% endif %} {% endif %}
{% else %} {% else %}
{% if perms.assignment.can_manage_assignment %} {% if perms.assignment.can_manage_assignment %}
@ -155,10 +158,10 @@
{% endif %} {% endif %}
{{ candidate }} {{ candidate }}
</td> </td>
{% for vote in votes %} {% for poll_dict in poll_list %}
{% if perms.assignment.can_manage_assignment %} {% if perms.assignment.can_manage_assignment or poll_dict.published %}
{# Hier stimmt es noch nicht. Es muss rein, dass veröffentlichte Wahlergebnisse für jedermann sichtbar sind #}
<td style="white-space:nowrap;"> <td style="white-space:nowrap;">
{% with vote=poll_dict.votes %}
{% if 'Yes' in vote and 'No' in vote and 'Abstain' in vote %} {% 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-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-no.png' %}" title="{% trans 'No' %}"> {{ vote.No }}<br>
@ -170,6 +173,7 @@
{% else %} {% else %}
&nbsp; &nbsp;
{% endif %} {% endif %}
{% endwith %}
</td> </td>
{% endif %} {% endif %}
{% endfor %} {% endfor %}