From b4e17b9b35df7ca83a3c2e6408f5a3767d324dd3 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sun, 25 Jan 2015 00:34:14 +0100 Subject: [PATCH] fix #1430 - anonymous user and motion detail view --- make/commands.py | 2 +- openslides/motion/models.py | 4 ++-- tests/integration/motion/__init__.py | 0 tests/integration/motion/test_views.py | 21 +++++++++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 tests/integration/motion/__init__.py create mode 100644 tests/integration/motion/test_views.py diff --git a/make/commands.py b/make/commands.py index 2676a6ff8..7fcd5da7f 100644 --- a/make/commands.py +++ b/make/commands.py @@ -14,7 +14,7 @@ def test(args=None): Runs the tests. """ module = getattr(args, 'module', '') - return call("DJANGO_SETTINGS_MODULE='tests.integration.settings' coverage run " + return call("DJANGO_SETTINGS_MODULE='tests.settings' coverage run " "./manage.py test tests.%s" % module) diff --git a/openslides/motion/models.py b/openslides/motion/models.py index ce9645c57..4d57bdba3 100644 --- a/openslides/motion/models.py +++ b/openslides/motion/models.py @@ -384,7 +384,7 @@ class Motion(SlideMixin, AbsoluteUrlMixin, models.Model): def is_submitter(self, person): """Return True, if person is a submitter of this motion. Else: False.""" - return self.submitter.filter(person=person).exists() + return self.submitter.filter(person=person.pk).exists() @property def supporters(self): @@ -400,7 +400,7 @@ class Motion(SlideMixin, AbsoluteUrlMixin, models.Model): """ Return True, if person is a supporter of this motion. Else: False. """ - return self.supporter.filter(person=person).exists() + return self.supporter.filter(person=person.pk).exists() def support(self, person): """ diff --git a/tests/integration/motion/__init__.py b/tests/integration/motion/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/integration/motion/test_views.py b/tests/integration/motion/test_views.py new file mode 100644 index 000000000..77d06b292 --- /dev/null +++ b/tests/integration/motion/test_views.py @@ -0,0 +1,21 @@ +from django.test.client import Client + +from openslides.utils.test import TestCase +from openslides.motion.models import Motion +from openslides.config.api import config + + +class AnonymousRequests(TestCase): + """ + Tests requests from the anonymous user. + """ + def setUp(self): + self.client = Client() + config['system_enable_anonymous'] = True + + def test_motion_detail(self): + Motion.objects.create(title='test_motion') + + response = self.client.get('/motion/1/') + + self.assertEqual(response.status_code, 200)