Merge pull request #4981 from emanuelschuetze/fixAmendmentUpdate

Fixed updating of amendments as normal user
This commit is contained in:
Emanuel Schütze 2019-09-05 14:54:24 +02:00 committed by GitHub
commit 081984d637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -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(

View File

@ -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.