From 5e5ab616122018da12853513927892237095152a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Fri, 4 Sep 2015 20:22:46 +0200 Subject: [PATCH] Removed poll_number field in MotionPoll model. --- .../migrations/0003_auto_20150904_2029.py | 19 +++++++++++++++++++ openslides/motions/models.py | 19 +++++-------------- tests/old/motions/test_models.py | 5 ----- 3 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 openslides/motions/migrations/0003_auto_20150904_2029.py diff --git a/openslides/motions/migrations/0003_auto_20150904_2029.py b/openslides/motions/migrations/0003_auto_20150904_2029.py new file mode 100644 index 000000000..12f3fe2d3 --- /dev/null +++ b/openslides/motions/migrations/0003_auto_20150904_2029.py @@ -0,0 +1,19 @@ +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('motions', '0002_auto_20150904_1448'), + ] + + operations = [ + migrations.AlterUniqueTogether( + name='motionpoll', + unique_together=set([]), + ), + migrations.RemoveField( + model_name='motionpoll', + name='poll_number', + ), + ] diff --git a/openslides/motions/models.py b/openslides/motions/models.py index 3992832cf..74c11879e 100644 --- a/openslides/motions/models.py +++ b/openslides/motions/models.py @@ -397,9 +397,7 @@ class Motion(RESTModelMixin, models.Model): Return the new poll object. """ if self.state.allow_create_poll: - # TODO: auto increment the poll_number in the database - poll_number = self.polls.aggregate(Max('poll_number'))['poll_number__max'] or 0 - poll = MotionPoll.objects.create(motion=self, poll_number=poll_number + 1) + poll = MotionPoll.objects.create(motion=self) poll.set_options() return poll else: @@ -678,18 +676,11 @@ class MotionPoll(RESTModelMixin, CollectDefaultVotesMixin, BasePoll): ugettext_noop('Yes'), ugettext_noop('No'), ugettext_noop('Abstain')] """The possible anwers for the poll. 'Yes, 'No' and 'Abstain'.""" - poll_number = models.PositiveIntegerField(default=1) - """An id for this poll in realation to a motion. - - Is unique for each motion. - """ - - class Meta: - unique_together = ("motion", "poll_number") - def __str__(self): - """Return a string, representing the poll.""" - return _('Vote %d') % self.poll_number + """ + Representation method only for debugging purposes. + """ + return 'MotionPoll for motion %s' % self.motion def set_options(self): """Create the option class for this poll.""" diff --git a/tests/old/motions/test_models.py b/tests/old/motions/test_models.py index d284a9c20..e9e0cc565 100644 --- a/tests/old/motions/test_models.py +++ b/tests/old/motions/test_models.py @@ -61,11 +61,6 @@ class ModelTest(TestCase): self.motion.supporters.remove(self.test_user) self.assertFalse(self.motion.is_supporter(self.test_user)) - def test_poll(self): - self.motion.state = State.objects.get(pk=1) - poll = self.motion.create_poll() - self.assertEqual(poll.poll_number, 1) - def test_state(self): self.motion.reset_state() self.assertEqual(self.motion.state.name, 'submitted')