diff --git a/apps/documents/__init__.py b/apps/documents/__init__.py index 0f4c17b197..ab03a92ff7 100755 --- a/apps/documents/__init__.py +++ b/apps/documents/__init__.py @@ -14,6 +14,8 @@ from staging import StagingFile from common.conf import settings as common_settings +from conf.settings import ENABLE_SINGLE_DOCUMENT_UPLOAD + PERMISSION_DOCUMENT_CREATE = 'document_create' PERMISSION_DOCUMENT_PROPERTIES_EDIT = 'document_properties_edit' PERMISSION_DOCUMENT_METADATA_EDIT = 'document_metadata_edit' @@ -55,7 +57,11 @@ staging_file_delete = {'text':_('delete'), 'view':'staging_file_delete', 'args': register_links(Document, [document_view, document_edit, document_edit_metadata, document_delete, document_download], menu_name='sidebar') register_links(Document, [document_list, document_create, document_create_multiple, document_create_sibling], menu_name='sidebar') -register_links(['document_list', 'document_create', 'document_create_multiple', 'upload_document_with_type', 'upload_multiple_documents_with_type'], [document_list, document_create, document_create_multiple], menu_name='sidebar') + +if ENABLE_SINGLE_DOCUMENT_UPLOAD: + register_links(['document_list', 'document_create', 'document_create_multiple', 'upload_document_with_type', 'upload_multiple_documents_with_type'], [document_list, document_create, document_create_multiple], menu_name='sidebar') +else: + register_links(['document_list', 'document_create', 'document_create_multiple', 'upload_document_with_type', 'upload_multiple_documents_with_type'], [document_list, document_create_multiple], menu_name='sidebar') register_links(DocumentPage, [document_page_go_back], menu_name='sidebar') @@ -76,9 +82,16 @@ register_model_list_columns(Document, [ ]) -register_menu([ - {'text':_('documents'), 'view':'document_create', 'links':[ - document_create, document_create_multiple, document_list - ],'famfam':'page','position':1}]) +print 'ENABLE_SINGLE_DOCUMENT_UPLOAD', ENABLE_SINGLE_DOCUMENT_UPLOAD +if ENABLE_SINGLE_DOCUMENT_UPLOAD: + register_menu([ + {'text':_('documents'), 'view':'document_create', 'links':[ + document_create, document_create_multiple, document_list + ],'famfam':'page','position':1}]) +else: + register_menu([ + {'text':_('documents'), 'view':'document_create_multiple', 'links':[ + document_create_multiple, document_list + ],'famfam':'page','position':1}]) TEMPORARY_DIRECTORY = common_settings.TEMPORARY_DIRECTORY if common_settings.TEMPORARY_DIRECTORY else tempfile.mkdtemp() diff --git a/apps/documents/conf/settings.py b/apps/documents/conf/settings.py index 055ff5ef8a..e95600a785 100755 --- a/apps/documents/conf/settings.py +++ b/apps/documents/conf/settings.py @@ -35,6 +35,7 @@ DELETE_STAGING_FILE_AFTER_UPLOAD = getattr(settings, 'DOCUMENTS_DELETE_STAGING_F STAGING_FILES_PREVIEW_SIZE = getattr(settings, 'DOCUMENTS_STAGING_FILES_PREVIEW_SIZE', '640x480') DELETE_LOCAL_ORIGINAL = getattr(settings, 'DOCUMENTS_DELETE_LOCAL_ORIGINAL', False) AUTOMATIC_OCR = getattr(settings, 'DOCUMENTS_AUTOMATIC_OCR', False) +ENABLE_SINGLE_DOCUMENT_UPLOAD = getattr(settings, 'DOCUMENTS_ENABLE_SINGLE_DOCUMENT_UPLOAD', True) # Saving CHECKSUM_FUNCTION = getattr(settings, 'DOCUMENTS_CHECKSUM_FUNCTION', lambda x: hashlib.sha256(x).hexdigest()) diff --git a/apps/documents/urls.py b/apps/documents/urls.py index c00262e869..ca503edbb1 100755 --- a/apps/documents/urls.py +++ b/apps/documents/urls.py @@ -6,6 +6,7 @@ from documents.conf.settings import PREVIEW_SIZE from documents.conf.settings import THUMBNAIL_SIZE from documents.conf.settings import DISPLAY_SIZE from documents.conf.settings import MULTIPAGE_PREVIEW_SIZE +from documents.conf.settings import ENABLE_SINGLE_DOCUMENT_UPLOAD from converter.api import QUALITY_HIGH @@ -25,7 +26,7 @@ urlpatterns = patterns('documents.views', url(r'^document/(?P\d+)/display/thumbnail/$', 'get_document_image', {'size':THUMBNAIL_SIZE}, 'document_thumbnail'), url(r'^document/(?P\d+)/display/$', 'get_document_image', {'size':DISPLAY_SIZE,'quality':QUALITY_HIGH}, 'document_display'), url(r'^document/(?P\d+)/download/$', 'document_download', (), 'document_download'), - url(r'^document/(?P\d+)/create/siblings/$', 'document_create_sibling', {'multiple':False}, 'document_create_sibling'), + url(r'^document/(?P\d+)/create/siblings/$', 'document_create_sibling', {'multiple':True if ENABLE_SINGLE_DOCUMENT_UPLOAD == False else False}, 'document_create_sibling'), url(r'^staging_file/(?P\w+)/preview/$', 'staging_file_preview', (), 'staging_file_preview'), url(r'^staging_file/(?P\w+)/delete/$', 'staging_file_delete', (), 'staging_file_delete'), diff --git a/settings.py b/settings.py index eec3157590..a47f3a5ea0 100755 --- a/settings.py +++ b/settings.py @@ -180,6 +180,7 @@ LOGIN_EXEMPT_URLS = ( #DOCUMENTS_DELETE_STAGING_FILE_AFTER_UPLOAD = False #DOCUMENTS_STAGING_FILES_PREVIEW_SIZE = '640x480' #DOCUMENTS_AUTOMATIC_OCR = False +#DOCUMENTS_ENABLE_SINGLE_DOCUMENT_UPLOAD = True # Saving