diff --git a/openslides/motion/forms.py b/openslides/motion/forms.py index 16320176b..cd86171d5 100644 --- a/openslides/motion/forms.py +++ b/openslides/motion/forms.py @@ -16,7 +16,7 @@ from django.utils.translation import ugettext as _, ugettext_lazy from openslides.utils.forms import CssClassMixin from openslides.utils.forms import CleanHtmlFormMixin from openslides.utils.person import PersonFormField, MultiplePersonFormField -from .models import Motion, Category +from .models import Motion, Category, Workflow class BaseMotionForm(CleanHtmlFormMixin, CssClassMixin, forms.ModelForm): @@ -134,6 +134,19 @@ class MotionIdentifierMixin(forms.ModelForm): fields = ('identifier',) +class MotionSetWorkflowMixin(forms.ModelForm): + """ + Mixin to let the user change the workflow of the motion. When he does + so, the motion's state is reset. + """ + + set_workflow = forms.ModelChoiceField( + queryset=Workflow.objects.all(), + required=False, + label=ugettext_lazy('Workflow'), + help_text=ugettext_lazy('Set a specific workflow to switch to it. If you do so, the state of the motion will be reset.')) + + class MotionImportForm(CssClassMixin, forms.Form): """ Form for motion import via csv file. diff --git a/openslides/motion/models.py b/openslides/motion/models.py index 6074c513a..02821b6ef 100644 --- a/openslides/motion/models.py +++ b/openslides/motion/models.py @@ -421,13 +421,16 @@ class Motion(SlideMixin, models.Model): self.set_identifier() self.state = state - def reset_state(self): + def reset_state(self, workflow=None): """ Set the state to the default state. - If the motion is new, it chooses the default workflow from config. + If the motion is new and workflow is None, it chooses the default + workflow from config. """ - if self.state: + if workflow: + new_state = workflow.first_state + elif self.state: new_state = self.state.workflow.first_state else: new_state = (Workflow.objects.get(pk=config['motion_workflow']).first_state or diff --git a/openslides/motion/signals.py b/openslides/motion/signals.py index 6c5d30f07..f418c2ef2 100644 --- a/openslides/motion/signals.py +++ b/openslides/motion/signals.py @@ -187,10 +187,11 @@ def create_builtin_workflows(sender, **kwargs): versioning=True) state_2_9 = State.objects.create(name=ugettext_noop('needs review'), workflow=workflow_2, + action_word=ugettext_noop('Needs review'), versioning=True) state_2_10 = State.objects.create(name=ugettext_noop('rejected (not authorized)'), workflow=workflow_2, - action_word=ugettext_noop('reject (not authorized)'), + action_word=ugettext_noop('Reject (not authorized)'), versioning=True) state_2_1.next_states.add(state_2_2, state_2_5, state_2_10) state_2_2.next_states.add(state_2_3, state_2_4, state_2_5, state_2_6, state_2_7, state_2_8, state_2_9) diff --git a/openslides/motion/templates/motion/motion_detail.html b/openslides/motion/templates/motion/motion_detail.html index ac1546352..38a13e401 100644 --- a/openslides/motion/templates/motion/motion_detail.html +++ b/openslides/motion/templates/motion/motion_detail.html @@ -57,7 +57,7 @@