From 08a3cf8490fea83af07c6755e857c3fe4e7ae7c9 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Fri, 9 Sep 2011 22:23:42 +0200 Subject: [PATCH] allow undocumented votecast and voteinvalid the poll-class has two new properties. voteinvalidf and votescastf. They show undocumented if the value is -2, else the value --- .../assignment/templates/assignment/view.html | 14 +++++++------- openslides/poll/forms.py | 4 ++-- openslides/poll/models.py | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/openslides/assignment/templates/assignment/view.html b/openslides/assignment/templates/assignment/view.html index b5a886dc4..58c6ee2eb 100644 --- a/openslides/assignment/templates/assignment/view.html +++ b/openslides/assignment/templates/assignment/view.html @@ -131,11 +131,11 @@ {% if poll.published %} {% else %} {% endif %} @@ -184,7 +184,7 @@ {% else %}∅{% endif %} {% endfor %} - {% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %} + {% if assignment.profile.exists and perms.assignment.can_manage_assignment and assignment.status == "vot" %} {% endif %} @@ -192,18 +192,18 @@ {%trans 'Invalid votes' %} {% for p in polls %} - {{ p.votesinvalid }} + {{ p.votesinvalidf }} {% endfor %} - {% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %} + {% if assignment.profile.exists and perms.assignment.can_manage_assignment and assignment.status == "vot" %} {% endif %} {%trans 'Votes cast' %} {% for p in polls %} - {{ p.votescast }} + {{ p.votescastf }} {% endfor %} - {% if assignment.profile.count > 0 and perms.assignment.can_manage_assignment and assignment.status == "vot" %} + {% if assignment.profile.exists and perms.assignment.can_manage_assignment and assignment.status == "vot" %} {% endif %} diff --git a/openslides/poll/forms.py b/openslides/poll/forms.py index 1b1507703..34a1c6082 100644 --- a/openslides/poll/forms.py +++ b/openslides/poll/forms.py @@ -20,8 +20,8 @@ class PollForm(ModelForm): error_css_class = 'error' required_css_class = 'required' - votescast = IntegerField(required=False,widget=TextInput(attrs={'class':'small-input'}),label=_("Votes cast")) - invalid = IntegerField(required=False, min_value=0, widget=TextInput(attrs={'class': 'small-input'}), label=_("Invalid")) + votescast = IntegerField(required=False, min_value=-2, widget=TextInput(attrs={'class':'small-input'}),label=_("Votes cast")) + invalid = IntegerField(required=False, min_value=-2, widget=TextInput(attrs={'class': 'small-input'}), label=_("Invalid")) class Meta: model = Poll diff --git a/openslides/poll/models.py b/openslides/poll/models.py index ab5300a9d..4013c20d7 100644 --- a/openslides/poll/models.py +++ b/openslides/poll/models.py @@ -40,6 +40,22 @@ class Poll(models.Model): optionc.save() return optionc + @property + def votescastf(self): + if self.votescast == -2: + return _('undocumented') + elif self.votescast: + return self.votescast + return '0' + + @property + def votesinvalidf(self): + if self.votesinvalid == -2: + return _('undocumented') + elif self.votesinvalid: + return self.votesinvalid + return '0' + def has_vote(self): for option in self.options: if option.voteyes or option.voteno or option.voteundesided: