Enabled the option to disabled version for motion update requests.
This commit is contained in:
parent
440a38b387
commit
01ee197eb6
@ -114,7 +114,7 @@ class MotionViewSet(ModelViewSet):
|
|||||||
data=request.data,
|
data=request.data,
|
||||||
partial=kwargs.get('partial', False))
|
partial=kwargs.get('partial', False))
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
updated_motion = serializer.save()
|
updated_motion = serializer.save(disable_versioning=request.data.get('disable_versioning'))
|
||||||
|
|
||||||
# Write the log message, check removal of supporters and initiate response.
|
# Write the log message, check removal of supporters and initiate response.
|
||||||
# TODO: Log if a version was updated.
|
# TODO: Log if a version was updated.
|
||||||
|
@ -7,7 +7,7 @@ from rest_framework.test import APIClient
|
|||||||
|
|
||||||
from openslides.core.config import config
|
from openslides.core.config import config
|
||||||
from openslides.core.models import Tag
|
from openslides.core.models import Tag
|
||||||
from openslides.motions.models import Category, Motion
|
from openslides.motions.models import Category, Motion, State
|
||||||
from openslides.utils.test import TestCase
|
from openslides.utils.test import TestCase
|
||||||
|
|
||||||
|
|
||||||
@ -220,6 +220,27 @@ class UpdateMotion(TestCase):
|
|||||||
self.assertEqual(motion.title, 'new_title_ohph1aedie5Du8sai2ye')
|
self.assertEqual(motion.title, 'new_title_ohph1aedie5Du8sai2ye')
|
||||||
self.assertEqual(motion.supporters.count(), 0)
|
self.assertEqual(motion.supporters.count(), 0)
|
||||||
|
|
||||||
|
def test_with_new_version(self):
|
||||||
|
self.motion.set_state(State.objects.get(name='permitted'))
|
||||||
|
self.motion.save()
|
||||||
|
response = self.client.patch(
|
||||||
|
reverse('motion-detail', args=[self.motion.pk]),
|
||||||
|
{'text': 'test_text_aeb1iaghahChong5od3a'})
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
motion = Motion.objects.get()
|
||||||
|
self.assertEqual(motion.versions.count(), 2)
|
||||||
|
|
||||||
|
def test_without_new_version(self):
|
||||||
|
self.motion.set_state(State.objects.get(name='permitted'))
|
||||||
|
self.motion.save()
|
||||||
|
response = self.client.patch(
|
||||||
|
reverse('motion-detail', args=[self.motion.pk]),
|
||||||
|
{'text': 'test_text_aeThaeroneiroo7Iophu',
|
||||||
|
'disable_versioning': True})
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
motion = Motion.objects.get()
|
||||||
|
self.assertEqual(motion.versions.count(), 1)
|
||||||
|
|
||||||
|
|
||||||
class ManageVersion(TestCase):
|
class ManageVersion(TestCase):
|
||||||
"""
|
"""
|
||||||
|
@ -47,8 +47,9 @@ class MotionViewSetUpdate(TestCase):
|
|||||||
@patch('openslides.motions.views.config')
|
@patch('openslides.motions.views.config')
|
||||||
def test_simple_update(self, mock_config):
|
def test_simple_update(self, mock_config):
|
||||||
self.request.user.has_perm.return_value = True
|
self.request.user.has_perm.return_value = True
|
||||||
|
self.request.data.get.return_value = versioning_mock = MagicMock()
|
||||||
self.view_instance.update(self.request)
|
self.view_instance.update(self.request)
|
||||||
self.mock_serializer.save.assert_called_with()
|
self.mock_serializer.save.assert_called_with(disable_versioning=versioning_mock)
|
||||||
|
|
||||||
@patch('openslides.motions.views.config')
|
@patch('openslides.motions.views.config')
|
||||||
def test_user_without_perms(self, mock_config):
|
def test_user_without_perms(self, mock_config):
|
||||||
|
Loading…
Reference in New Issue
Block a user