Show initial submitters in the update-form
This commit is contained in:
parent
8708ba5da6
commit
567e6c975a
@ -27,12 +27,12 @@ class BaseMotionForm(forms.ModelForm, CssClassMixin):
|
|||||||
fields = ()
|
fields = ()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
motion = kwargs.get('instance', None)
|
self.motion = kwargs.get('instance', None)
|
||||||
if motion is not None:
|
self.initial = kwargs.setdefault('initial', {})
|
||||||
initial = kwargs.setdefault('initial', {})
|
if self.motion is not None:
|
||||||
initial['title'] = motion.title
|
self.initial['title'] = self.motion.title
|
||||||
initial['text'] = motion.text
|
self.initial['text'] = self.motion.text
|
||||||
initial['reason'] = motion.reason
|
self.initial['reason'] = self.motion.reason
|
||||||
super(BaseMotionForm, self).__init__(*args, **kwargs)
|
super(BaseMotionForm, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
title = forms.CharField(widget=forms.TextInput(), label=_("Title"))
|
title = forms.CharField(widget=forms.TextInput(), label=_("Title"))
|
||||||
@ -44,6 +44,13 @@ class BaseMotionForm(forms.ModelForm, CssClassMixin):
|
|||||||
class MotionSubmitterMixin(forms.ModelForm):
|
class MotionSubmitterMixin(forms.ModelForm):
|
||||||
submitter = MultiplePersonFormField(label=_("Submitter"))
|
submitter = MultiplePersonFormField(label=_("Submitter"))
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
if self.motion is not None:
|
||||||
|
submitter = [submitter.person.person_id for submitter in self.motion.submitter.all()]
|
||||||
|
print submitter
|
||||||
|
self.initial['submitter'] = submitter
|
||||||
|
super(MotionSubmitterMixin, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class MotionSupporterMixin(forms.ModelForm):
|
class MotionSupporterMixin(forms.ModelForm):
|
||||||
supporter = MultiplePersonFormField(required=False, label=_("Supporters"))
|
supporter = MultiplePersonFormField(required=False, label=_("Supporters"))
|
||||||
|
Loading…
Reference in New Issue
Block a user