diff --git a/openslides/application/models.py b/openslides/application/models.py
index 3eb00d636..728ae393d 100644
--- a/openslides/application/models.py
+++ b/openslides/application/models.py
@@ -496,12 +496,7 @@ class ApplicationOption(BaseOption):
def __getattr__(self, name):
if name in ['yes', 'no', 'contained']:
try:
- value = self.get_votes().get(value=name).weight
- if value == -1:
- return _('majority')
- if value == -2:
- return _('undocumented')
- return value
+ return self.get_votes().get(value=name)
except Vote.DoesNotExist:
pass
raise AttributeError(name)
@@ -517,6 +512,7 @@ class ApplicationPoll(BasePoll, CountInvalid, CountVotesCast):
return self.application
def set_options(self):
+ #TODO: maybe it is possible with .create() to call this without poll=self
self.get_option_class()(poll=self).save()
def append_pollform_fields(self, fields):
diff --git a/openslides/application/templates/application/view.html b/openslides/application/templates/application/view.html
index 10cc82ce2..cad41af32 100644
--- a/openslides/application/templates/application/view.html
+++ b/openslides/application/templates/application/view.html
@@ -79,9 +79,9 @@
{{ option.yes }}
{{ option.no }}
{{ option.contained }}
- {{ poll.votesinvalid }}
+ {{ poll.print_votesinvalid }}
-
{{ poll.votescast }}
+
{{ poll.poll_votescast }}
{% endwith %}
{% if perms.application.can_manage_application %}
diff --git a/openslides/assignment/models.py b/openslides/assignment/models.py
index 553f2a899..519d1395a 100644
--- a/openslides/assignment/models.py
+++ b/openslides/assignment/models.py
@@ -17,6 +17,7 @@ from participant.models import Profile
from projector.models import Slide
from projector.api import register_slidemodel
+from poll.models import BasePoll, CountInvalid, CountVotesCast, BaseOption
class Assignment(models.Model, Slide):
@@ -73,7 +74,7 @@ class Assignment(models.Model, Slide):
@property
def candidates(self):
- return Profile.objects.filter(option__poll__assignment=self).order_by('user__first_name').distinct()
+ return self.profile.get_query_set()
def set_elected(self, profile, value=True):
if profile in self.candidates:
@@ -88,33 +89,9 @@ class Assignment(models.Model, Slide):
return False
def gen_poll(self):
- from poll.models import Poll
- poll = Poll()
-
- candidates = list(self.profile.all())
- for elected in self.elected.all():
- try:
- candidates.remove(elected)
- except ValueError:
- pass
-
- # Option A: candidates <= available posts -> yes/no/abstention
- if len(candidates) <= self.posts - self.elected.count():
- poll.optiondecision = True
- else:
- poll.optiondecision = False
-
- # Option B: candidates == 1 -> yes/no/abstention
- #if self.profile.count() == 1:
- # poll.optiondecision = True
- #else:
- # poll.optiondecision = False
-
- poll.assignment = self
- poll.description = self.polldescription
+ poll = AssignmentPoll(assignment=self)
poll.save()
- for candidate in candidates:
- poll.add_option(candidate)
+ poll.set_options([{'candidate': profile} for profile in self.profile.all()])
return poll
def slide(self):
@@ -146,3 +123,23 @@ class Assignment(models.Model, Slide):
)
register_slidemodel(Assignment)
+
+class AssignmentOption(BaseOption):
+ candidate = models.ForeignKey(Profile)
+
+ def __unicode__(self):
+ return unicode(self.candidate)
+
+
+class AssignmentPoll(BasePoll, CountInvalid, CountVotesCast):
+ option_class = AssignmentOption
+
+ assignment = models.ForeignKey(Assignment, related_name='poll_set')
+
+ def get_assignment(self):
+ return self.assignment
+
+
+ def append_pollform_fields(self, fields):
+ CountInvalid.append_pollform_fields(self, fields)
+ CountVotesCast.append_pollform_fields(self, fields)
diff --git a/openslides/assignment/templates/assignment/poll_view.html b/openslides/assignment/templates/assignment/poll_view.html
index 2ebb5ba2c..62e4b1ea3 100644
--- a/openslides/assignment/templates/assignment/poll_view.html
+++ b/openslides/assignment/templates/assignment/poll_view.html
@@ -12,37 +12,32 @@
{% trans "Short description" %}: {{ poll.description }}
-1 := {% trans 'majority' %}, -2 := {% trans 'undocumented' %}