diff --git a/openslides/agenda/templates/beamer/ItemAssignment.html b/openslides/agenda/templates/beamer/ItemAssignment.html
index 0ec9fde26..b55ef5475 100644
--- a/openslides/agenda/templates/beamer/ItemAssignment.html
+++ b/openslides/agenda/templates/beamer/ItemAssignment.html
@@ -35,14 +35,18 @@
{% endif %}
- {% if item.assignment.poll_set.all.count > 0 %}
+ {% with polls|first as firstpoll %}
+ {% if polls.count > 0 and firstpoll.published %}
+
{% trans "Election results" %}
{% trans "Candidates" %} |
{% for poll in item.assignment.poll_set.all %}
- {{forloop.counter}}. {% trans "ballot" %} |
+ {% if poll.published %}
+ {{forloop.counter}}. {% trans "ballot" %} |
+ {% endif %}
{% endfor %}
{% for vote in votes %}
@@ -77,17 +81,22 @@
{%trans 'Invalid votes' %} |
{% for p in polls %}
+ {% if p.published %}
{{ p.votesinvalid }} |
+ {% endif %}
{% endfor %}
{%trans 'Votes cast' %} |
{% for p in polls %}
+ {% if p.published %}
{{ p.votescast }} |
+ {% endif %}
{% endfor %}
{% endif %}
+ {% endwith %}
{% endblock %}
diff --git a/openslides/agenda/views.py b/openslides/agenda/views.py
index f26610350..e29a47921 100644
--- a/openslides/agenda/views.py
+++ b/openslides/agenda/views.py
@@ -115,14 +115,15 @@ def assignment_votes(item):
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:
+ 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)
return votes
diff --git a/openslides/assignment/templates/assignment/view.html b/openslides/assignment/templates/assignment/view.html
index 411a8e4d0..9830e24f3 100644
--- a/openslides/assignment/templates/assignment/view.html
+++ b/openslides/assignment/templates/assignment/view.html
@@ -130,6 +130,11 @@
{% if perms.assignment.can_manage_assignment %}
+ {% if poll.published %}
+ unpublish
+ {% else %}
+ publish
+ {% endif %}
{% endif %}
{% endfor %}
diff --git a/openslides/assignment/urls.py b/openslides/assignment/urls.py
index 0edffe2ad..8cef45fb6 100644
--- a/openslides/assignment/urls.py
+++ b/openslides/assignment/urls.py
@@ -58,6 +58,12 @@ urlpatterns = patterns('assignment.views',
url(r'^assignment/poll/(?P\d+)/del$', 'delete_poll', \
name='assignment_poll_delete'),
+ url(r'^assignment/poll/(?P\d+)/pub/$', 'set_published', {'published': True},
+ name='assignment_poll_publish'),
+
+ url(r'^assignment/poll/(?P\d+)/notpub/$', 'set_published', {'published': False},
+ name='assignment_poll_notpublish'),
+
url(r'^assignment/(?P\d+)/elected/(?P\d+)$', 'set_elected', {'elected': True}, \
name='assignment_user_elected'),
diff --git a/openslides/assignment/views.py b/openslides/assignment/views.py
index 111b50cc7..940a8a64a 100644
--- a/openslides/assignment/views.py
+++ b/openslides/assignment/views.py
@@ -234,6 +234,19 @@ def poll_view(request, poll_id):
'ballotnumber': ballotnumber,
}
+@permission_required('assignment.can_manage_assignment')
+def set_published(request, poll_id, published=True):
+ try:
+ poll = Poll.objects.get(pk=poll_id)
+ print poll.published
+ poll.set_published(published)
+ if poll.published:
+ messages.success(request, _("Poll successfully set to published.") )
+ else:
+ messages.success(request, _("Poll successfully set to unpublished.") )
+ except Poll.DoesNotExist:
+ messages.error(request, _('Poll ID %d does not exist.') % int(poll_id))
+ return redirect(reverse('assignment_view', args=[poll.id]))
@permission_required('assignment.can_manage_assignment')
def delete_poll(request, poll_id):
diff --git a/openslides/poll/models.py b/openslides/poll/models.py
index 90047355f..d3ffdc578 100644
--- a/openslides/poll/models.py
+++ b/openslides/poll/models.py
@@ -25,6 +25,7 @@ class Poll(models.Model):
description = models.TextField(null=True, blank=True, verbose_name = _("Description"))
votescast = models.IntegerField(null=True, blank=True, verbose_name = _("Votes cast"))
votesinvalid = models.IntegerField(null=True, blank=True, verbose_name = _("Votes invalid"))
+ published = models.BooleanField(default=False)
def add_option(self, option):
self.save()
@@ -56,6 +57,13 @@ class Poll(models.Model):
def options_values(self):
return [option.value for option in self.options]
+ def set_published(self, published=True):
+ """
+ Changes the published-status of the poll.
+ """
+ self.published = published
+ self.save()
+
@property
def count_ballots(self):
if self.application: