Fixed #724
The motion updated view now uses the last_versio instead of the active_Version
This commit is contained in:
parent
097d369c89
commit
42ad1113fa
@ -51,13 +51,16 @@ class BaseMotionForm(CleanHtmlFormMixin, CssClassMixin, forms.ModelForm):
|
|||||||
fields = ()
|
fields = ()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Fill the FormFields releated to the version data with initial data."""
|
"""
|
||||||
|
Fill the FormFields releated to the version data with initial data.
|
||||||
|
"""
|
||||||
self.motion = kwargs.get('instance', None)
|
self.motion = kwargs.get('instance', None)
|
||||||
self.initial = kwargs.setdefault('initial', {})
|
self.initial = kwargs.setdefault('initial', {})
|
||||||
if self.motion is not None:
|
if self.motion is not None:
|
||||||
self.initial['title'] = self.motion.title
|
last_version = self.motion.get_last_version()
|
||||||
self.initial['text'] = self.motion.text
|
self.initial['title'] = last_version.title
|
||||||
self.initial['reason'] = self.motion.reason
|
self.initial['text'] = last_version.text
|
||||||
|
self.initial['reason'] = last_version.reason
|
||||||
else:
|
else:
|
||||||
self.initial['text'] = config['motion_preamble']
|
self.initial['text'] = config['motion_preamble']
|
||||||
super(BaseMotionForm, self).__init__(*args, **kwargs)
|
super(BaseMotionForm, self).__init__(*args, **kwargs)
|
||||||
|
@ -283,6 +283,22 @@ class TestMotionUpdateView(MotionViewTestCase):
|
|||||||
allow_support=False)
|
allow_support=False)
|
||||||
motion.save()
|
motion.save()
|
||||||
|
|
||||||
|
def test_form_version_content(self):
|
||||||
|
"""
|
||||||
|
The content seen in the update view should be the last version
|
||||||
|
independently from the active_version.
|
||||||
|
"""
|
||||||
|
motion = Motion.objects.create(title='test', text='wrowerjlgw')
|
||||||
|
new_version = motion.get_new_version()
|
||||||
|
new_version.text = 'tpdfgojwerldkfgertdfg'
|
||||||
|
motion.save(use_version=new_version)
|
||||||
|
motion.active_version = motion.versions.all()[0]
|
||||||
|
motion.save(use_version=False)
|
||||||
|
self.assertNotEqual(motion.active_version, motion.get_last_version())
|
||||||
|
|
||||||
|
response = self.admin_client.get('/motion/%s/edit/' % motion.id)
|
||||||
|
self.assertEqual(response.context['form'].initial['text'], 'tpdfgojwerldkfgertdfg')
|
||||||
|
|
||||||
|
|
||||||
class TestMotionDeleteView(MotionViewTestCase):
|
class TestMotionDeleteView(MotionViewTestCase):
|
||||||
def test_get(self):
|
def test_get(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user