#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
|
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
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,21 +158,22 @@
|
|||||||
{% 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;">
|
||||||
{% if 'Yes' in vote and 'No' in vote and 'Abstain' in vote %}
|
{% with vote=poll_dict.votes %}
|
||||||
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Yes' %}"> {{ vote.Yes }}<br>
|
{% if 'Yes' in vote and 'No' in vote and 'Abstain' in vote %}
|
||||||
<img src="{% static 'images/icons/voting-no.png' %}" title="{% trans 'No' %}"> {{ vote.No }}<br>
|
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Yes' %}"> {{ vote.Yes }}<br>
|
||||||
<img src="{% static 'images/icons/voting-abstention.png' %}" title="{% trans 'Abstention' %}"> {{ vote.Abstain }}<br>
|
<img src="{% static 'images/icons/voting-no.png' %}" title="{% trans 'No' %}"> {{ vote.No }}<br>
|
||||||
{% elif 'Votes' in vote %}
|
<img src="{% static 'images/icons/voting-abstention.png' %}" title="{% trans 'Abstention' %}"> {{ vote.Abstain }}<br>
|
||||||
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Yes' %}"> {{ vote.Votes }}
|
{% elif 'Votes' in vote %}
|
||||||
{% elif vote == None %}
|
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Yes' %}"> {{ vote.Votes }}
|
||||||
{% trans 'was not a <br> candidate'%}
|
{% elif vote == None %}
|
||||||
{% else %}
|
{% trans 'was not a <br> candidate'%}
|
||||||
|
{% else %}
|
||||||
{% endif %}
|
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
Loading…
Reference in New Issue
Block a user