Standardize the way storages are used. All apps that use storage now define their storages in the .storages modules instead of the .runtime module. The storage.backends.filebasedstorage.FileBasedStorage has been remove, instead Django's default storage is used and each app is responsible of specifying their default path.

Signed-off-by: Michael Price <loneviking72@gmail.com>
This commit is contained in:
Michael Price
2018-04-03 02:32:28 -04:00
parent 1076d5f1ff
commit 424d6a5af9
17 changed files with 63 additions and 87 deletions
+2 -2
View File
@@ -12,7 +12,7 @@ from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from .managers import ErrorLogEntryManager
from .runtime import shared_storage_backend
from .storages import sharedupload_storage
def upload_to(instance, filename):
@@ -47,7 +47,7 @@ class ErrorLogEntry(models.Model):
@python_2_unicode_compatible
class SharedUploadedFile(models.Model):
file = models.FileField(
storage=shared_storage_backend, upload_to=upload_to,
storage=sharedupload_storage, upload_to=upload_to,
verbose_name=_('File')
)
filename = models.CharField(max_length=255, verbose_name=_('Filename'))
-5
View File
@@ -1,5 +0,0 @@
from django.utils.module_loading import import_string
from .settings import setting_shared_storage
shared_storage_backend = import_string(setting_shared_storage.value)()
+5 -1
View File
@@ -38,9 +38,13 @@ setting_paginate_by = namespace.add_setting(
)
setting_shared_storage = namespace.add_setting(
global_name='COMMON_SHARED_STORAGE',
default='storage.backends.filebasedstorage.FileBasedStorage',
default='django.core.files.storage.FileSystemStorage',
help_text=_('A storage backend that all workers can use to share files.')
)
setting_shared_storage_arguments = namespace.add_setting(
global_name='COMMON_SHARED_STORAGE_ARGUMENTS',
default='{location: mayan/media/shared_files}',
)
setting_temporary_directory = namespace.add_setting(
global_name='COMMON_TEMPORARY_DIRECTORY', default=tempfile.gettempdir(),
help_text=_(
+17
View File
@@ -0,0 +1,17 @@
from __future__ import unicode_literals
import yaml
from django.utils.module_loading import import_string
from .settings import (
setting_shared_storage, setting_shared_storage_arguments
)
sharedupload_storage = import_string(
dotted_path=setting_shared_storage.value
)(
**yaml.safe_load(
setting_shared_storage_arguments.value or '{}'
)
)