#253 don't show unpublished polls for nonmanager in assignment view
This commit is contained in:
parent
47ff052c22
commit
ef5b9e3281
@ -128,16 +128,19 @@ class Assignment(models.Model, SlideMixin):
|
||||
continue
|
||||
vote_results_dict[candidate] = []
|
||||
for poll in polls:
|
||||
votes = {
|
||||
'votes': {},
|
||||
'published': poll.published,
|
||||
}
|
||||
try:
|
||||
polloption = poll.get_options().get(candidate=candidate)
|
||||
# candidate is related to this poll
|
||||
votes = {}
|
||||
for vote in polloption.get_votes():
|
||||
votes[vote.value] = vote.get_weight()
|
||||
vote_results_dict[candidate].append(votes)
|
||||
# candidate related to this poll
|
||||
poll_option = poll.get_options().get(candidate=candidate)
|
||||
for vote in poll_option.get_votes():
|
||||
votes['votes'][vote.value] = vote.get_weight()
|
||||
except AssignmentOption.DoesNotExist:
|
||||
# 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
|
||||
|
||||
|
||||
|
@ -139,14 +139,17 @@
|
||||
{% endif %}
|
||||
</tr>
|
||||
|
||||
{% for candidate, votes in vote_results.items %}
|
||||
{% for candidate, poll_list in vote_results.items %}
|
||||
<tr class="{% cycle 'odd' '' %}">
|
||||
<td class="candidate">
|
||||
{% if candidate in assignment.elected.all %}
|
||||
{% 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>
|
||||
{% 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 %}
|
||||
{% else %}
|
||||
{% if perms.assignment.can_manage_assignment %}
|
||||
@ -155,21 +158,22 @@
|
||||
{% endif %}
|
||||
{{ candidate }}
|
||||
</td>
|
||||
{% for vote in votes %}
|
||||
{% if perms.assignment.can_manage_assignment %}
|
||||
{# Hier stimmt es noch nicht. Es muss rein, dass veröffentlichte Wahlergebnisse für jedermann sichtbar sind #}
|
||||
{% for poll_dict in poll_list %}
|
||||
{% if perms.assignment.can_manage_assignment or poll_dict.published %}
|
||||
<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'%}
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
{% with vote=poll_dict.votes %}
|
||||
{% 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 %}
|
||||
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in New Issue
Block a user