Merge pull request #719 from normanjaeckel/TranslateWorkflow
Insert LocalizedModelChoiceField for use in MotionSetWorkflowMixin.
This commit is contained in:
commit
76a0d232dc
@ -14,8 +14,7 @@ from django import forms
|
||||
from django.utils.translation import ugettext as _, ugettext_lazy
|
||||
|
||||
from openslides.config.api import config
|
||||
from openslides.utils.forms import CssClassMixin
|
||||
from openslides.utils.forms import CleanHtmlFormMixin
|
||||
from openslides.utils.forms import CssClassMixin, CleanHtmlFormMixin, LocalizedModelChoiceField
|
||||
from openslides.utils.person import PersonFormField, MultiplePersonFormField
|
||||
from .models import Motion, Category, Workflow
|
||||
|
||||
@ -144,7 +143,7 @@ class MotionSetWorkflowMixin(forms.ModelForm):
|
||||
so, the motion's state is reset.
|
||||
"""
|
||||
|
||||
set_workflow = forms.ModelChoiceField(
|
||||
set_workflow = LocalizedModelChoiceField(
|
||||
queryset=Workflow.objects.all(),
|
||||
required=False,
|
||||
label=ugettext_lazy('Workflow'),
|
||||
|
@ -13,7 +13,7 @@
|
||||
import bleach
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy
|
||||
from django.utils.translation import ugettext as _, ugettext_lazy
|
||||
|
||||
|
||||
# Allowed tags, attributes and styles allowed in textareas edited with a JS
|
||||
@ -48,6 +48,18 @@ class CssClassMixin(object):
|
||||
required_css_class = 'required'
|
||||
|
||||
|
||||
class LocalizedModelChoiceField(forms.ModelChoiceField):
|
||||
"""
|
||||
Subclass of Django's ModelChoiceField to translate the labels of the
|
||||
model's objects.
|
||||
"""
|
||||
def label_from_instance(self, *args, **kwargs):
|
||||
"""
|
||||
Translates the output from Django's label_from_instance method.
|
||||
"""
|
||||
return _(super(LocalizedModelChoiceField, self).label_from_instance(*args, **kwargs))
|
||||
|
||||
|
||||
class LocalizedModelMultipleChoiceField(forms.ModelMultipleChoiceField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.to_field_name = kwargs.get('to_field_name', None)
|
||||
|
Loading…
Reference in New Issue
Block a user