From 52f7dff0f1dceae657e86e073ef80cbeec30d081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Wed, 28 May 2014 00:20:13 +0200 Subject: [PATCH] Fixed bug with workflows. Fixed #1309. --- openslides/motion/signals.py | 4 ++-- openslides/motion/views.py | 2 +- tests/config/test_config.py | 6 +++--- tests/motion/test_views.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openslides/motion/signals.py b/openslides/motion/signals.py index 616de8e58..aba69d1bb 100644 --- a/openslides/motion/signals.py +++ b/openslides/motion/signals.py @@ -21,12 +21,12 @@ def setup_motion_config(sender, **kwargs): # General motion_workflow = ConfigVariable( name='motion_workflow', - default_value=1, + default_value='1', form_field=forms.ChoiceField( widget=forms.Select(), label=ugettext_lazy('Workflow of new motions'), 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( name='motion_identifier', default_value='per_category', diff --git a/openslides/motion/views.py b/openslides/motion/views.py index 9baacfbd1..829421665 100644 --- a/openslides/motion/views.py +++ b/openslides/motion/views.py @@ -197,7 +197,7 @@ class MotionCreateView(MotionEditMixin, CreateView): Sets first state according to given or default workflow and initiates 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.version = self.object.get_new_version() diff --git a/tests/config/test_config.py b/tests/config/test_config.py index f4eaf0a0b..9a20553fc 100644 --- a/tests/config/test_config.py +++ b/tests/config/test_config.py @@ -27,7 +27,7 @@ class HandleConfigTest(TestCase): self.assertEqual(config['string_var'], 'default_string_rien4ooCZieng6ah') self.assertTrue(config['bool_var']) 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.assertRaisesMessage(expected_exception=ConfigNotFound, 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') choices_var = ConfigVariable( name='choices_var', - default_value=1, - form_field=forms.ChoiceField(choices=((1, 'Choice One Ughoch4ocoche6Ee'), (2, 'Choice Two Vahnoh5yalohv5Eb')))) + default_value='1', + 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)) return ConfigGroupedCollection( diff --git a/tests/motion/test_views.py b/tests/motion/test_views.py index 7cbe55934..8b47f0310 100644 --- a/tests/motion/test_views.py +++ b/tests/motion/test_views.py @@ -120,7 +120,7 @@ class TestMotionCreateView(MotionViewTestCase): response = self.admin_client.post(self.url, {'title': 'new motion', 'text': 'motion text', 'reason': 'motion reason', - 'workflow': 1}) + 'workflow': '1'}) self.assertEqual(response.status_code, 302) self.assertTrue(Motion.objects.filter(versions__title='new motion').exists())