diff --git a/openslides/motion/models.py b/openslides/motion/models.py index fb1274094..ea2485020 100644 --- a/openslides/motion/models.py +++ b/openslides/motion/models.py @@ -100,7 +100,7 @@ class Motion(SlideMixin, models.Model): """ Return a human readable name of this motion. """ - return self.active_version.title + return self.get_active_version().title # TODO: Use transaction def save(self, use_version=None, *args, **kwargs): diff --git a/tests/motion/test_models.py b/tests/motion/test_models.py index 66f5ad13f..9db4cc796 100644 --- a/tests/motion/test_models.py +++ b/tests/motion/test_models.py @@ -146,6 +146,12 @@ class ModelTest(TestCase): motion.save(use_version=False) self.assertEqual(motion.versions.count(), 2) + def test_unicode_with_no_active_version(self): + motion = Motion.objects.create(title='foo', text='bar', identifier='') + motion.active_version = None + motion.save(update_fields=['active_version']) + self.assertEqual(str(motion), 'foo') # motion.__unicode__() did rais an AttributeError + class ConfigTest(TestCase): def test_stop_submitting(self):