From bb38d8b85eaf23750aefdb3d864bdbcef75d0495 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Tue, 6 Sep 2011 22:22:29 +0200 Subject: [PATCH] Updated application PDF. Added vote results. --- openslides/application/models.py | 40 +++++-- .../templates/application/view.html | 4 +- openslides/application/views.py | 5 +- openslides/utils/pdf.py | 100 ++++++++++++++---- 4 files changed, 119 insertions(+), 30 deletions(-) diff --git a/openslides/application/models.py b/openslides/application/models.py index c953acd8d..59f4f2889 100644 --- a/openslides/application/models.py +++ b/openslides/application/models.py @@ -17,6 +17,7 @@ from django.db.models import Max from django.contrib.auth.models import User from django.utils.translation import ugettext as _ +from openslides.participant.models import Profile from openslides.system.api import config_get @@ -142,6 +143,18 @@ class Application(models.Model): min_supporters = int(config_get('application_min_supporters')) return self.supporter.count() >= min_supporters + @property + def missing_supporters(self): + """ + Return number of missing supporters + """ + min_supporters = int(config_get('application_min_supporters')) + delta = min_supporters - self.supporter.count() + if delta > 0: + return delta + else: + return 0 + def save(self, user=None, nonewversion=False): """ Save the Application, and create a new AVersion if necessary @@ -293,13 +306,16 @@ class Application(models.Model): or (self.status == "per" \ and user.has_perm("application.can_manage_application")): actions.append("wit") - + try: # Check if the user can support and unspoort the application - if self.status == "pub" \ - and user != self.submitter \ - and user not in self.supporter.all(): - actions.append("support") - + if self.status == "pub" \ + and user != self.submitter \ + and user not in self.supporter.all() \ + and user.profile: + actions.append("support") + except Profile.DoesNotExist: + pass + if self.status == "pub" and user in self.supporter.all(): actions.append("unsupport") @@ -388,6 +404,18 @@ class Application(models.Model): self.writelog(_("Poll created"), user) return poll + @property + def results(self): + """ + Return a list of voting results + """ + results = [] + for poll in self.poll_set.all(): + for option in poll.options: + if poll.votesinvalid != None and poll.votescast != None: + results.append([option.yes, option.no, option.undesided, poll.votesinvalid, poll.votescast]) + return results + @models.permalink def get_absolute_url(self, link='view'): if link == 'view': diff --git a/openslides/application/templates/application/view.html b/openslides/application/templates/application/view.html index e303f9a1a..e0e599975 100644 --- a/openslides/application/templates/application/view.html +++ b/openslides/application/templates/application/view.html @@ -60,8 +60,8 @@