Improved error message reporting when creating filesystem directories or links

This commit is contained in:
Roberto Rosario
2011-02-04 13:17:36 -04:00
parent d80584d087
commit c7b098b41f
2 changed files with 6 additions and 4 deletions

View File

@@ -87,17 +87,16 @@ class Document(models.Model):
if exc.errno == errno.EEXIST:
pass
else:
raise 'Unable to create metadata indexing directory.'
return _(u'Unable to create metadata indexing directory.')
target_filepath = os.path.join(target_directory, os.extsep.join([slugify(self.file_filename), slugify(self.file_extension)]))
try:
os.symlink(os.path.abspath(self.file.path), target_filepath)
except OSError as exc:
if exc.errno == errno.EEXIST:
pass
else:
raise 'Unable to create metadata indexing directory.'
return _(u'Unable to create metadata indexing symbolic link.')
available_functions_string = (_(u' Available functions: %s') % ','.join(['%s()' % name for name, function in AVAILABLE_FUNCTIONS.items()])) if AVAILABLE_FUNCTIONS else ''

View File

@@ -61,7 +61,10 @@ def upload_document_with_type(request, document_type_id, multiple=True):
document_metadata.save()
messages.success(request, _(u'Document uploaded successfully.'))
instance.create_fs_links()
error_msg = instance.create_fs_links()
if error_msg:
messages.error(request, error_msg)
if multiple:
return HttpResponseRedirect(request.get_full_path())
else: