Merge pull request #1868 from normanjaeckel/TrivialChanges
Enabled the option to disabled version for motion update requests.
This commit is contained in:
commit
4ffbd8be29
@ -120,7 +120,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
|
||||||
|
|
||||||
|
|
||||||
@ -221,6 +221,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)
|
||||||
|
|
||||||
|
|
||||||
class MotionViewSetManageVersion(TestCase):
|
class MotionViewSetManageVersion(TestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user