From ef5b9e328167a23c7c109e8c093143ed783ba4b8 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Wed, 4 Jul 2012 16:05:31 +0200 Subject: [PATCH] #253 don't show unpublished polls for nonmanager in assignment view --- openslides/assignment/models.py | 17 ++++--- .../assignment/templates/assignment/view.html | 46 ++++++++++--------- 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/openslides/assignment/models.py b/openslides/assignment/models.py index d9828e273..ae024e537 100644 --- a/openslides/assignment/models.py +++ b/openslides/assignment/models.py @@ -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 diff --git a/openslides/assignment/templates/assignment/view.html b/openslides/assignment/templates/assignment/view.html index 1647a9c69..73f7fc98d 100644 --- a/openslides/assignment/templates/assignment/view.html +++ b/openslides/assignment/templates/assignment/view.html @@ -99,7 +99,7 @@ {% if polls %} - + {% with ballotnumber=polls.count %} @@ -108,7 +108,7 @@ {% endwith %} - + {% for poll in polls %} @@ -138,15 +138,18 @@ {% endif %} - - {% for candidate, votes in vote_results.items %} + + {% for candidate, poll_list in vote_results.items %} - {% 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 %} {% endif %} {% endfor %} @@ -178,7 +182,7 @@ {% endif %} {% endfor %} - + {% for poll in polls %} @@ -190,7 +194,7 @@ {% endif %} - + {% for poll in polls %}
{% trans "Candidates" %}
{% if candidate in assignment.elected.all %} {% if perms.assignment.can_manage_assignment %} + {# What does this line do #} {% else %} - + + + {% endif %} {% else %} {% if perms.assignment.can_manage_assignment %} @@ -155,21 +158,22 @@ {% endif %} {{ candidate }} - {% if 'Yes' in vote and 'No' in vote and 'Abstain' in vote %} - {{ vote.Yes }}
- {{ vote.No }}
- {{ vote.Abstain }}
- {% elif 'Votes' in vote %} - {{ vote.Votes }} - {% elif vote == None %} - {% trans 'was not a
candidate'%} - {% else %} -   - {% endif %} + {% with vote=poll_dict.votes %} + {% if 'Yes' in vote and 'No' in vote and 'Abstain' in vote %} + {{ vote.Yes }}
+ {{ vote.No }}
+ {{ vote.Abstain }}
+ {% elif 'Votes' in vote %} + {{ vote.Votes }} + {% elif vote == None %} + {% trans 'was not a
candidate'%} + {% else %} +   + {% endif %} + {% endwith %}
{%trans 'Invalid votes' %}
{%trans 'Votes cast' %}