Added a new setup option: FILESYSTEM_INDEXING_AVAILABLE_FUNCTIONS - a dictionary to allow users to add custom functions
This commit is contained in:
@@ -8,6 +8,7 @@ from filesystem_serving.conf.settings import FILESERVING_ENABLE
|
||||
from filesystem_serving.conf.settings import FILESERVING_PATH
|
||||
from filesystem_serving.conf.settings import SLUGIFY_PATHS
|
||||
from filesystem_serving.conf.settings import MAX_RENAME_COUNT
|
||||
from filesystem_serving.conf.settings import AVAILABLE_INDEXING_FUNCTIONS
|
||||
|
||||
from models import DocumentMetadataIndex, Document
|
||||
|
||||
@@ -27,7 +28,7 @@ def document_create_fs_links(document):
|
||||
for metadata_index in document.document_type.metadataindex_set.all():
|
||||
if metadata_index.enabled:
|
||||
try:
|
||||
fabricated_directory = eval(metadata_index.expression, metadata_dict)
|
||||
fabricated_directory = eval(metadata_index.expression, metadata_dict, AVAILABLE_INDEXING_FUNCTIONS)
|
||||
target_directory = os.path.join(FILESERVING_PATH, fabricated_directory)
|
||||
try:
|
||||
os.makedirs(target_directory)
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
from django.conf import settings
|
||||
|
||||
from common.utils import proper_name
|
||||
|
||||
available_indexing_functions = {
|
||||
'proper_name':proper_name
|
||||
}
|
||||
|
||||
|
||||
# Serving
|
||||
FILESERVING_ENABLE = getattr(settings, 'FILESYSTEM_FILESERVING_ENABLE', True)
|
||||
FILESERVING_PATH = getattr(settings, 'FILESYSTEM_FILESERVING_PATH', u'/tmp/mayan/documents')
|
||||
SLUGIFY_PATHS = getattr(settings, 'FILESYSTEM_SLUGIFY_PATHS', False)
|
||||
MAX_RENAME_COUNT = getattr(settings, 'FILESYSTEM_MAX_RENAME_COUNT', 200)
|
||||
AVAILABLE_INDEXING_FUNCTIONS = getattr(settings, 'FILESYSTEM_INDEXING_AVAILABLE_FUNCTIONS', available_indexing_functions)
|
||||
|
||||
Reference in New Issue
Block a user