Do not redefine imported slugify function
This commit is contained in:
@@ -1,13 +0,0 @@
|
|||||||
from django.http import HttpResponse
|
|
||||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
|
||||||
|
|
||||||
def sendfile(request, filename):
|
|
||||||
return = HttpResponse(IterFile(filename))
|
|
||||||
|
|
||||||
class IterFile(object):
|
|
||||||
def __init__(self, filename):
|
|
||||||
self.file = SimpleUploadedFile(name=filename, content=open(filename).read())
|
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
return self.file.chunks()
|
|
||||||
|
|
||||||
@@ -15,7 +15,9 @@ from filesystem_serving.models import DocumentMetadataIndex, Document
|
|||||||
|
|
||||||
if SLUGIFY_PATHS == False:
|
if SLUGIFY_PATHS == False:
|
||||||
#Do not slugify path or filenames and extensions
|
#Do not slugify path or filenames and extensions
|
||||||
slugify = lambda x: x
|
SLUGIFY_FUNCTION = lambda x: x
|
||||||
|
else:
|
||||||
|
SLUGIFY_FUNCTION = slugify
|
||||||
|
|
||||||
|
|
||||||
def document_create_fs_links(document):
|
def document_create_fs_links(document):
|
||||||
@@ -24,7 +26,7 @@ def document_create_fs_links(document):
|
|||||||
if not document.exists():
|
if not document.exists():
|
||||||
raise Exception(_(u'Not creating metadata indexing, document not found in document storage'))
|
raise Exception(_(u'Not creating metadata indexing, document not found in document storage'))
|
||||||
metadata_dict = {'document': document}
|
metadata_dict = {'document': document}
|
||||||
metadata_dict.update(dict([(metadata.metadata_type.name, slugify(metadata.value)) for metadata in document.documentmetadata_set.all()]))
|
metadata_dict.update(dict([(metadata.metadata_type.name, SLUGIFY_FUNCTION(metadata.value)) for metadata in document.documentmetadata_set.all()]))
|
||||||
|
|
||||||
for metadata_index in document.document_type.metadataindex_set.all():
|
for metadata_index in document.document_type.metadataindex_set.all():
|
||||||
if metadata_index.enabled:
|
if metadata_index.enabled:
|
||||||
@@ -39,7 +41,7 @@ def document_create_fs_links(document):
|
|||||||
else:
|
else:
|
||||||
raise OSError(_(u'Unable to create metadata indexing directory: %s') % exc)
|
raise OSError(_(u'Unable to create metadata indexing directory: %s') % exc)
|
||||||
|
|
||||||
next_available_filename(document, metadata_index, target_directory, slugify(document.file_filename), slugify(document.file_extension))
|
next_available_filename(document, metadata_index, target_directory, SLUGIFY_FUNCTION(document.file_filename), SLUGIFY_FUNCTION(document.file_extension))
|
||||||
except NameError, exc:
|
except NameError, exc:
|
||||||
warnings.append(_(u'Error in metadata indexing expression: %s') % exc)
|
warnings.append(_(u'Error in metadata indexing expression: %s') % exc)
|
||||||
#raise NameError()
|
#raise NameError()
|
||||||
|
|||||||
Reference in New Issue
Block a user