Fix the new version fields in the upload form

This commit is contained in:
Roberto Rosario
2011-12-03 23:37:00 -04:00
parent e81a02b18d
commit 986b7e39e4

View File

@@ -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
@@ -170,14 +168,11 @@ class DocumentForm(forms.ModelForm):
queryset=filenames_qs, queryset=filenames_qs,
required=False, required=False,
label=_(u'Quick document rename')) label=_(u'Quick document rename'))
if instance:
self.version_fields(instance)
def version_fields(self, document): def version_fields(self, document):
self.fields['comment'] = forms.CharField(
label=_(u'Comment'),
required=False,
widget=forms.widgets.Textarea(attrs={'rows': 4}),
)
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
) )