fix yes-no-abstain-poll in assigmnet-projector
This commit is contained in:
parent
ebc81d9236
commit
a21a96026b
@ -113,9 +113,13 @@ class Assignment(models.Model, SlideMixin):
|
|||||||
publish_winner_results_only = config["assignment_publish_winner_results_only"]
|
publish_winner_results_only = config["assignment_publish_winner_results_only"]
|
||||||
# list of votes
|
# list of votes
|
||||||
votes = []
|
votes = []
|
||||||
for candidate in self.candidates:
|
options = []
|
||||||
|
polls = self.poll_set.all()
|
||||||
|
for poll in polls:
|
||||||
|
options += poll.get_options()
|
||||||
|
for candidate in set([option.candidate for option in options]):
|
||||||
tmplist = [[candidate, self.is_elected(candidate)], []]
|
tmplist = [[candidate, self.is_elected(candidate)], []]
|
||||||
for poll in self.poll_set.all():
|
for poll in polls:
|
||||||
if poll.published:
|
if poll.published:
|
||||||
if poll.get_options().filter(candidate=candidate).exists():
|
if poll.get_options().filter(candidate=candidate).exists():
|
||||||
# check config option 'publish_winner_results_only'
|
# check config option 'publish_winner_results_only'
|
||||||
@ -123,7 +127,7 @@ class Assignment(models.Model, SlideMixin):
|
|||||||
or publish_winner_results_only and self.is_elected(candidate):
|
or publish_winner_results_only and self.is_elected(candidate):
|
||||||
option = AssignmentOption.objects.filter(poll=poll).get(candidate=candidate)
|
option = AssignmentOption.objects.filter(poll=poll).get(candidate=candidate)
|
||||||
try:
|
try:
|
||||||
tmplist[1].append(option.get_votes()[0])
|
tmplist[1].append(option.get_votes())
|
||||||
except IndexError:
|
except IndexError:
|
||||||
tmplist[1].append('–')
|
tmplist[1].append('–')
|
||||||
else:
|
else:
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
<p><br></p>
|
<p><br></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if polls.count > 0 %}
|
{% if polls.exists %}
|
||||||
<h3>{% trans "Election results" %}</h3>
|
<h3>{% trans "Election results" %}</h3>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@ -60,25 +60,30 @@
|
|||||||
{% for vote in votes %}
|
{% for vote in votes %}
|
||||||
<tr class="{% cycle 'odd' '' %}">
|
<tr class="{% cycle 'odd' '' %}">
|
||||||
{% with vote|first as candidate %}
|
{% with vote|first as candidate %}
|
||||||
<td class="candidate {% if candidate.1 %}elected{% endif %}">
|
<td class="candidate{% if candidate.1 %} elected{% endif %}">
|
||||||
{% if candidate.1 %}
|
{% if candidate.1 %}
|
||||||
<a class="elected"><img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Candidate is elected' %}"></a>
|
<a class="elected">
|
||||||
{% endif %}
|
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Candidate is elected' %}">
|
||||||
{{ candidate.0 }}
|
</a>
|
||||||
</td>
|
{% endif %}
|
||||||
{% for v in vote|last %}
|
{{ candidate.0 }}
|
||||||
<td style="white-space:nowrap;" {% if candidate.1 %}class="elected"{% endif %}>{% if v %}
|
</td>
|
||||||
{% if v|length == 3 %}
|
{% for v in vote|last %}
|
||||||
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Yes' %}"> {% if v.0 %}{{ v.0 }}{% else %}∅{% endif %}<br>
|
<td style="white-space:nowrap;" {% if candidate.1 %}class="elected"{% endif %}>
|
||||||
<img src="{% static 'images/icons/voting-no.png' %}" title="{% trans 'No' %}"> {% if v.1 %}{{ v.1 }}{% else %}∅{% endif %}<br>
|
{% if v %}
|
||||||
<img src="{% static 'images/icons/voting-abstention.png' %}" title="{% trans 'Abstention' %}"> {% if v.2 %}{{ v.2 }}{% else %}∅{% endif %}<br>
|
{% if v|length == 3 %}
|
||||||
{% else %}
|
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Yes' %}"> {% if v.0 %}{{ v.0 }}{% else %}∅{% endif %}<br>
|
||||||
{% if v != "-" %}<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Yes' %}">{% endif %}
|
<img src="{% static 'images/icons/voting-no.png' %}" title="{% trans 'No' %}"> {% if v.1 %}{{ v.1 }}{% else %}∅{% endif %}<br>
|
||||||
{{ v }}
|
<img src="{% static 'images/icons/voting-abstention.png' %}" title="{% trans 'Abstention' %}"> {% if v.2 %}{{ v.2 }}{% else %}∅{% endif %}<br>
|
||||||
|
{% else %}
|
||||||
|
{% if v != "-" %}
|
||||||
|
<img src="{% static 'images/icons/voting-yes.png' %}" title="{% trans 'Yes' %}">
|
||||||
|
{% endif %}
|
||||||
|
{{ v.0 }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
|
Loading…
Reference in New Issue
Block a user