diff --git a/HISTORY.rst b/HISTORY.rst index c561e137fa..71723a5e9a 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -117,6 +117,19 @@ - Support passing arguments to the document, document cache and document signatures storage backends. New settings: DOCUMENTS_STORAGE_BACKEND_ARGUMENTS, DOCUMENTS_CACHE_STORAGE_BACKEND_ARGUMENTS, SIGNATURES_STORAGE_BACKEND_ARGUMENTS +- Support passing arguments to the document, document cache and document signatures + storage backends. New settings: DOCUMENTS_STORAGE_BACKEND_ARGUMENTS, + DOCUMENTS_CACHE_STORAGE_BACKEND_ARGUMENTS, SIGNATURES_STORAGE_BACKEND_ARGUMENTS +- Remove the setting STORAGE_FILESTORAGE_LOCATION. Document storage + location for the storage.backend.filebasedstorage.FileBasedStorage + backdend must now passed via the DOCUMENTS_STORAGE_BACKEND_ARGUMENTS, + DOCUMENTS_CACHE_STORAGE_BACKEND_ARGUMENTS, or + SIGNATURES_STORAGE_BACKEND_ARGUMENTS if the backend is used to documents, + the document image cache and/or document signatures. Use + DOCUMENTS_STORAGE_BACKEND_ARGUMENTS = '{ location: }' + If no path is specified the backend will default to + 'mayan/media/document_storage'. + 2.7.3 (2017-09-11) ================== diff --git a/mayan/apps/storage/backends/compressedstorage.py b/mayan/apps/storage/backends/compressedstorage.py index d76fa76294..008c575bc4 100644 --- a/mayan/apps/storage/backends/compressedstorage.py +++ b/mayan/apps/storage/backends/compressedstorage.py @@ -17,8 +17,6 @@ except ImportError: from django.core.files import File from django.core.files.storage import FileSystemStorage -from ..settings import FILESTORAGE_LOCATION - class CompressedStorage(FileSystemStorage): """Simple wrapper for the stock Django FileSystemStorage class""" @@ -26,8 +24,8 @@ class CompressedStorage(FileSystemStorage): separator = os.path.sep def __init__(self, *args, **kwargs): + self.location = kwargs.pop('location') super(CompressedStorage, self).__init__(*args, **kwargs) - self.location = FILESTORAGE_LOCATION def save(self, name, content): descriptor = StringIO() diff --git a/mayan/apps/storage/backends/filebasedstorage.py b/mayan/apps/storage/backends/filebasedstorage.py index e446f7401b..dfd3757ba9 100644 --- a/mayan/apps/storage/backends/filebasedstorage.py +++ b/mayan/apps/storage/backends/filebasedstorage.py @@ -3,8 +3,9 @@ from __future__ import unicode_literals import os from django.core.files.storage import FileSystemStorage +from django.conf import settings -from ..settings import setting_filestorage_location +from .literals import DEFAULT_PATH class FileBasedStorage(FileSystemStorage): @@ -13,5 +14,7 @@ class FileBasedStorage(FileSystemStorage): separator = os.path.sep def __init__(self, *args, **kwargs): + self.location = kwargs.pop( + 'location', os.path.join(settings.MEDIA_ROOT, DEFAULT_PATH) + ) super(FileBasedStorage, self).__init__(*args, **kwargs) - self.location = setting_filestorage_location.value diff --git a/mayan/apps/storage/backends/literals.py b/mayan/apps/storage/backends/literals.py new file mode 100644 index 0000000000..74d1d49b1b --- /dev/null +++ b/mayan/apps/storage/backends/literals.py @@ -0,0 +1,3 @@ +from __future__ import unicode_literals + +DEFAULT_PATH = 'document_storage' diff --git a/mayan/apps/storage/settings.py b/mayan/apps/storage/settings.py deleted file mode 100644 index 12184f50bd..0000000000 --- a/mayan/apps/storage/settings.py +++ /dev/null @@ -1,14 +0,0 @@ -from __future__ import unicode_literals - -import os - -from django.conf import settings -from django.utils.translation import ugettext_lazy as _ - -from smart_settings import Namespace - -namespace = Namespace(name='storage', label=_('Storage')) -setting_filestorage_location = namespace.add_setting( - global_name='STORAGE_FILESTORAGE_LOCATION', - default=os.path.join(settings.MEDIA_ROOT, 'document_storage'), is_path=True -)