From a86b835c0b4d1ffeb98c3523cc965ade13139322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Sch=C3=BCtze?= Date: Thu, 5 Sep 2019 09:34:36 +0200 Subject: [PATCH] Fixed updating of amendments as normal user for paragraph based amendments --- openslides/motions/views.py | 2 +- tests/integration/motions/test_viewset.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/openslides/motions/views.py b/openslides/motions/views.py index 80da4f09d..98140c2f6 100644 --- a/openslides/motions/views.py +++ b/openslides/motions/views.py @@ -278,7 +278,7 @@ class MotionViewSet(TreeSortMixin, ModelViewSet): whitelist: List[str] = [] # Add title, text and reason to the whitelist only, if the user is the submitter. if motion.is_submitter(request.user) and motion.state.allow_submitter_edit: - whitelist.extend(("title", "text", "reason")) + whitelist.extend(("title", "text", "reason", "amendment_paragraphs")) if has_perm(request.user, "motions.can_manage_metadata"): whitelist.extend( diff --git a/tests/integration/motions/test_viewset.py b/tests/integration/motions/test_viewset.py index d63d9cbac..97e1170e9 100644 --- a/tests/integration/motions/test_viewset.py +++ b/tests/integration/motions/test_viewset.py @@ -584,6 +584,29 @@ class UpdateMotion(TestCase): motion = Motion.objects.get() self.assertEqual(motion.text, "test_text_xeigheeha7thopubeu4U") + def test_patch_amendment_paragraphs_no_manage_perms(self): + admin = get_user_model().objects.get(username="admin") + admin.groups.remove(GROUP_ADMIN_PK) + admin.groups.add(GROUP_DELEGATE_PK) + Submitter.objects.add(admin, self.motion) + self.motion.state.allow_submitter_edit = True + self.motion.state.save() + inform_changed_data(admin) + + response = self.client.patch( + reverse("motion-detail", args=[self.motion.pk]), + {"amendment_paragraphs": ["test_paragraph_39fo8qcpcaFMmjfaD2Lb"]}, + format="json", + ) + self.assertEqual(response.status_code, status.HTTP_200_OK) + motion = Motion.objects.get() + self.assertTrue(isinstance(motion.amendment_paragraphs, list)) + self.assertEqual(len(motion.amendment_paragraphs), 1) + self.assertEqual( + motion.amendment_paragraphs[0], "test_paragraph_39fo8qcpcaFMmjfaD2Lb" + ) + self.assertEqual(motion.text, "") + def test_patch_workflow(self): """ Tests to only update the workflow of a motion.