diff --git a/openslides/application/models.py b/openslides/application/models.py
index 1264b259e..496c3dff1 100644
--- a/openslides/application/models.py
+++ b/openslides/application/models.py
@@ -412,16 +412,15 @@ class Application(models.Model, Slide):
"""
Generates a poll object for the application
"""
- poll = ApplicationPoll()
+ poll = ApplicationPoll(application=self)
poll.save()
- poll.set_options([{'application': self}])
+ poll.set_options()
self.writelog(_("Poll created"), user)
return poll
@property
def polls(self):
- #todo: return an query_set
- return [option.poll for option in self.applicationoption_set.all()]
+ return self.applicationpoll_set.all()
@property
def results(self):
@@ -493,14 +492,24 @@ register_slidemodel(Application)
class ApplicationOption(BaseOption):
- application = models.ForeignKey(Application)
- def __unicode__(self):
- return unicode(self.application)
+ def __getattr__(self, name):
+ if name in [_('yes'), _('no'), _('contained')]:
+ print self.poll.get_vote_values()
+ try:
+ return self.get_votes().get(value=name)
+ except Vote.DoesNotExist:
+ pass
+ raise AttributeError(name)
class ApplicationPoll(BasePoll):
option_class = ApplicationOption
+ application = models.ForeignKey(Application)
+
def get_application(self):
- return self.get_options()[0].application
+ return self.application
+
+ def set_options(self):
+ self.get_option_class()(poll=self).save()
diff --git a/openslides/application/templates/application/view.html b/openslides/application/templates/application/view.html
index e3cc2ad5f..eb121c571 100644
--- a/openslides/application/templates/application/view.html
+++ b/openslides/application/templates/application/view.html
@@ -74,16 +74,16 @@
{% endif %}
{% trans 'project' %}
- {% if poll.has_vote %}
- {% for option in poll.options %}
- {{ option.yes }}
- {{ option.no }}
- {{ option.undesided }}
+ {% if poll.has_votes %}
+ {% with poll.get_options.0 as option %}
+ {{ option.yes.weight }}
+ {{ option.no.weight }}
+ {{ option.contained.weight }}
{{ poll.votesinvalidf }}