In ExportToModel workflow, for model_file attribute, check the content type first before checking the file extension

Also test if base_filename is not None.
This commit is contained in:
Benjamin Dauvergne 2011-06-21 20:07:55 +00:00
parent ac72dfb6f5
commit b83dde334f
1 changed files with 5 additions and 1 deletions

View File

@ -835,8 +835,12 @@ class ExportToModel(WorkflowStatusItem):
return formdata.get_url() + self.get_directory_name()
def model_file_validation(self, upload):
if upload.base_filename.endswith('.rtf'):
if upload.content_type and upload.content_type == 'application/rtf':
return True, ''
if (upload.content_type and upload.content_type == 'application/octet-stream') or \
upload.content_type is None:
if upload.base_filename and upload.base_filename.endswith('.rtf'):
return True, ''
return False, _('Only RTF files can be used')
def add_parameters_widgets(self, form, parameters, prefix='', formdef=None):