Fixed bug with workflows. Fixed #1309.

This commit is contained in:
Norman Jäckel 2014-05-28 00:20:13 +02:00
parent c5db1c5e02
commit 52f7dff0f1
4 changed files with 7 additions and 7 deletions

View File

@ -21,12 +21,12 @@ def setup_motion_config(sender, **kwargs):
# General # General
motion_workflow = ConfigVariable( motion_workflow = ConfigVariable(
name='motion_workflow', name='motion_workflow',
default_value=1, default_value='1',
form_field=forms.ChoiceField( form_field=forms.ChoiceField(
widget=forms.Select(), widget=forms.Select(),
label=ugettext_lazy('Workflow of new motions'), label=ugettext_lazy('Workflow of new motions'),
required=True, required=True,
choices=[(workflow.pk, ugettext_lazy(workflow.name)) for workflow in Workflow.objects.all()])) choices=[(str(workflow.pk), ugettext_lazy(workflow.name)) for workflow in Workflow.objects.all()]))
motion_identifier = ConfigVariable( motion_identifier = ConfigVariable(
name='motion_identifier', name='motion_identifier',
default_value='per_category', default_value='per_category',

View File

@ -197,7 +197,7 @@ class MotionCreateView(MotionEditMixin, CreateView):
Sets first state according to given or default workflow and initiates Sets first state according to given or default workflow and initiates
a new version. a new version.
""" """
workflow = form.cleaned_data.get('workflow', config['motion_workflow']) workflow = form.cleaned_data.get('workflow', int(config['motion_workflow']))
self.object.reset_state(workflow) self.object.reset_state(workflow)
self.version = self.object.get_new_version() self.version = self.object.get_new_version()

View File

@ -27,7 +27,7 @@ class HandleConfigTest(TestCase):
self.assertEqual(config['string_var'], 'default_string_rien4ooCZieng6ah') self.assertEqual(config['string_var'], 'default_string_rien4ooCZieng6ah')
self.assertTrue(config['bool_var']) self.assertTrue(config['bool_var'])
self.assertEqual(config['integer_var'], 3) self.assertEqual(config['integer_var'], 3)
self.assertEqual(config['choices_var'], 1) self.assertEqual(config['choices_var'], '1')
self.assertEqual(config['none_config_var'], None) self.assertEqual(config['none_config_var'], None)
self.assertRaisesMessage(expected_exception=ConfigNotFound, self.assertRaisesMessage(expected_exception=ConfigNotFound,
expected_message='The config variable unknown_config_var was not found.', expected_message='The config variable unknown_config_var was not found.',
@ -308,8 +308,8 @@ def set_grouped_config_view(sender, **kwargs):
default_value='hidden_value') default_value='hidden_value')
choices_var = ConfigVariable( choices_var = ConfigVariable(
name='choices_var', name='choices_var',
default_value=1, default_value='1',
form_field=forms.ChoiceField(choices=((1, 'Choice One Ughoch4ocoche6Ee'), (2, 'Choice Two Vahnoh5yalohv5Eb')))) form_field=forms.ChoiceField(choices=(('1', 'Choice One Ughoch4ocoche6Ee'), ('2', 'Choice Two Vahnoh5yalohv5Eb'))))
group_2 = ConfigGroup(title='Group 2 Toongai7ahyahy7B', variables=(hidden_var, choices_var)) group_2 = ConfigGroup(title='Group 2 Toongai7ahyahy7B', variables=(hidden_var, choices_var))
return ConfigGroupedCollection( return ConfigGroupedCollection(

View File

@ -120,7 +120,7 @@ class TestMotionCreateView(MotionViewTestCase):
response = self.admin_client.post(self.url, {'title': 'new motion', response = self.admin_client.post(self.url, {'title': 'new motion',
'text': 'motion text', 'text': 'motion text',
'reason': 'motion reason', 'reason': 'motion reason',
'workflow': 1}) 'workflow': '1'})
self.assertEqual(response.status_code, 302) self.assertEqual(response.status_code, 302)
self.assertTrue(Motion.objects.filter(versions__title='new motion').exists()) self.assertTrue(Motion.objects.filter(versions__title='new motion').exists())