From 1e248ebf23fd927fa252d0cc9391b34f99addb96 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Fri, 9 Sep 2011 16:34:01 +0200 Subject: [PATCH] Only show published polls for normal users. --- .../assignment/templates/assignment/view.html | 6 ++++++ openslides/assignment/views.py | 15 ++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/openslides/assignment/templates/assignment/view.html b/openslides/assignment/templates/assignment/view.html index b5a886dc4..0d921ad23 100644 --- a/openslides/assignment/templates/assignment/view.html +++ b/openslides/assignment/templates/assignment/view.html @@ -125,6 +125,7 @@ {% trans "Candidates" %} {% for poll in assignment.poll_set.all %} + {% if poll.published and not perms.assignment.can_manage_assignment or perms.assignment.can_manage_assignment %} {% if perms.assignment.can_manage_assignment %}{% endif %} {{ forloop.counter }}. {% trans 'ballot' %} {% if perms.assignment.can_manage_assignment %} @@ -141,6 +142,7 @@ {% endif %} + {% endif %} {% endfor %} {% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %} @@ -192,7 +194,9 @@ {%trans 'Invalid votes' %} {% for p in polls %} + {% if p.published and not perms.assignment.can_manage_assignment or perms.assignment.can_manage_assignment %} {{ p.votesinvalid }} + {% endif %} {% endfor %} {% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %} @@ -201,7 +205,9 @@ {%trans 'Votes cast' %} {% for p in polls %} + {% if p.published and not perms.assignment.can_manage_assignment or perms.assignment.can_manage_assignment %} {{ p.votescast }} + {% endif %} {% endfor %} {% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %} diff --git a/openslides/assignment/views.py b/openslides/assignment/views.py index 21cb01467..4e64fd4ff 100644 --- a/openslides/assignment/views.py +++ b/openslides/assignment/views.py @@ -69,14 +69,15 @@ def view(request, assignment_id=None): for candidate in assignment.candidates: tmplist = [[candidate, assignment.is_elected(candidate)], []] for poll in assignment.poll_set.all(): - if candidate in poll.options_values: - option = Option.objects.filter(poll=poll).filter(user=candidate)[0] - if poll.optiondecision: - tmplist[1].append([option.yes, option.no, option.undesided]) + if (poll.published and not request.user.has_perm('assignment.can_manage_assignment')) or request.user.has_perm('assignment.can_manage_assignment'): + if candidate in poll.options_values: + option = Option.objects.filter(poll=poll).filter(user=candidate)[0] + if poll.optiondecision: + tmplist[1].append([option.yes, option.no, option.undesided]) + else: + tmplist[1].append(option.yes) else: - tmplist[1].append(option.yes) - else: - tmplist[1].append("-") + tmplist[1].append("-") votes.append(tmplist) polls = []