Implmented conditional show of expand checkbox, initial support for conditional highlight (buggy)

This commit is contained in:
Roberto Rosario
2011-07-06 03:11:48 -04:00
parent ee3abd16ec
commit 2739ad9027
7 changed files with 66 additions and 348 deletions

View File

@@ -20,6 +20,7 @@ class StagingDocumentForm(DocumentForm):
"""
def __init__(self, *args, **kwargs):
cls = kwargs.pop('cls')
show_expand = kwargs.pop('show_expand', False)
super(StagingDocumentForm, self).__init__(*args, **kwargs)
try:
self.fields['staging_file_id'].choices = [
@@ -28,6 +29,12 @@ class StagingDocumentForm(DocumentForm):
except:
pass
if show_expand:
self.fields['expand'] = forms.BooleanField(
label=_(u'Expand compressed files'), required=False,
help_text=ugettext(u'Upload a compressed file\'s contained files as individual documents')
)
# Put staging_list field first in the field order list
staging_list_index = self.fields.keyOrder.index('staging_file_id')
staging_list = self.fields.keyOrder.pop(staging_list_index)
@@ -37,3 +44,15 @@ class StagingDocumentForm(DocumentForm):
class Meta(DocumentForm.Meta):
exclude = ('description', 'file', 'document_type', 'tags')
class WebFormForm(DocumentForm):
def __init__(self, *args, **kwargs):
show_expand = kwargs.pop('show_expand', False)
super(WebFormForm, self).__init__(*args, **kwargs)
if show_expand:
self.fields['expand'] = forms.BooleanField(
label=_(u'Expand compressed files'), required=False,
help_text=ugettext(u'Upload a compressed file\'s contained files as individual documents')
)