Fix the new version fields in the upload form
This commit is contained in:
@@ -151,8 +151,6 @@ class DocumentForm(forms.ModelForm):
|
|||||||
instance = kwargs.pop('instance', None)
|
instance = kwargs.pop('instance', None)
|
||||||
|
|
||||||
super(DocumentForm, self).__init__(*args, **kwargs)
|
super(DocumentForm, self).__init__(*args, **kwargs)
|
||||||
if instance:
|
|
||||||
self.version_fields(instance)
|
|
||||||
|
|
||||||
if 'document_type' in self.fields:
|
if 'document_type' in self.fields:
|
||||||
# To allow merging with DocumentForm_edit
|
# To allow merging with DocumentForm_edit
|
||||||
@@ -171,13 +169,10 @@ class DocumentForm(forms.ModelForm):
|
|||||||
required=False,
|
required=False,
|
||||||
label=_(u'Quick document rename'))
|
label=_(u'Quick document rename'))
|
||||||
|
|
||||||
def version_fields(self, document):
|
if instance:
|
||||||
self.fields['comment'] = forms.CharField(
|
self.version_fields(instance)
|
||||||
label=_(u'Comment'),
|
|
||||||
required=False,
|
|
||||||
widget=forms.widgets.Textarea(attrs={'rows': 4}),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
def version_fields(self, document):
|
||||||
self.fields['version_update'] = forms.ChoiceField(
|
self.fields['version_update'] = forms.ChoiceField(
|
||||||
label=_(u'Version update'),
|
label=_(u'Version update'),
|
||||||
choices=DocumentVersion.get_version_update_choices(document.latest_version)
|
choices=DocumentVersion.get_version_update_choices(document.latest_version)
|
||||||
@@ -197,6 +192,12 @@ class DocumentForm(forms.ModelForm):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.fields['comment'] = forms.CharField(
|
||||||
|
label=_(u'Comment'),
|
||||||
|
required=False,
|
||||||
|
widget=forms.widgets.Textarea(attrs={'rows': 4}),
|
||||||
|
)
|
||||||
|
|
||||||
new_filename = forms.CharField(
|
new_filename = forms.CharField(
|
||||||
label=_('New document filename'), required=False
|
label=_('New document filename'), required=False
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user