Backport FakeStorageSubclass from versions/next
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -28,6 +28,9 @@
|
|||||||
doing atabase etup.
|
doing atabase etup.
|
||||||
- Added support for YAML encoded environment variables to the platform
|
- Added support for YAML encoded environment variables to the platform
|
||||||
templates apps.
|
templates apps.
|
||||||
|
- Move YAML code to its own module.
|
||||||
|
- Move Django and Celery settings.
|
||||||
|
- Backport FakeStorageSubclass from versions/next.
|
||||||
|
|
||||||
3.2.6 (2019-07-10)
|
3.2.6 (2019-07-10)
|
||||||
==================
|
==================
|
||||||
|
|||||||
@@ -38,6 +38,14 @@ Changes
|
|||||||
is now done using MAYAN_DATABASES to mirror Django way of doing database setup.
|
is now done using MAYAN_DATABASES to mirror Django way of doing database setup.
|
||||||
- Added support for YAML encoded environment variables to the platform
|
- Added support for YAML encoded environment variables to the platform
|
||||||
templates apps.
|
templates apps.
|
||||||
|
- Move YAML code to its own module. Code now resides in common.serialization
|
||||||
|
in the form of two new functions: yaml_load and yaml_dump.
|
||||||
|
- Move Django and Celery settings. Django settings now reside in the smart
|
||||||
|
settings app. Celery settings now reside in the task manager app.
|
||||||
|
- Backport FakeStorageSubclass from versions/next. Placeholder class to allow
|
||||||
|
serializing the real storage subclass to support migrations.
|
||||||
|
Used by all configurable storages.
|
||||||
|
|
||||||
|
|
||||||
Removals
|
Removals
|
||||||
--------
|
--------
|
||||||
|
|||||||
32
mayan/apps/common/migrations/0012_auto_20190711_0548.py
Normal file
32
mayan/apps/common/migrations/0012_auto_20190711_0548.py
Normal file
File diff suppressed because one or more lines are too long
@@ -1,11 +1,11 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.utils.module_loading import import_string
|
from mayan.apps.storage.utils import get_storage_subclass
|
||||||
|
|
||||||
from .settings import (
|
from .settings import (
|
||||||
setting_shared_storage, setting_shared_storage_arguments
|
setting_shared_storage, setting_shared_storage_arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
storage_sharedupload = import_string(
|
storage_sharedupload = get_storage_subclass(
|
||||||
dotted_path=setting_shared_storage.value
|
dotted_path=setting_shared_storage.value
|
||||||
)(**setting_shared_storage_arguments.value)
|
)(**setting_shared_storage_arguments.value)
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.22 on 2019-07-11 05:44
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import mayan.apps.document_signatures.models
|
||||||
|
import mayan.apps.storage.classes
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('document_signatures', '0008_auto_20180429_0759'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='detachedsignature',
|
||||||
|
name='signature_file',
|
||||||
|
field=models.FileField(blank=True, null=True, storage=mayan.apps.storage.classes.FakeStorageSubclass(), upload_to=mayan.apps.document_signatures.models.upload_to, verbose_name='Signature file'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.utils.module_loading import import_string
|
from mayan.apps.storage.utils import get_storage_subclass
|
||||||
|
|
||||||
from .settings import (
|
from .settings import (
|
||||||
setting_storage_backend, setting_storage_backend_arguments
|
setting_storage_backend, setting_storage_backend_arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
storage_detachedsignature = import_string(
|
storage_detachedsignature = get_storage_subclass(
|
||||||
dotted_path=setting_storage_backend.value
|
dotted_path=setting_storage_backend.value
|
||||||
)(**setting_storage_backend_arguments.value)
|
)(**setting_storage_backend_arguments.value)
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.utils.module_loading import import_string
|
from mayan.apps.storage.utils import get_storage_subclass
|
||||||
|
|
||||||
from .settings import (
|
from .settings import (
|
||||||
setting_workflowimagecache_storage,
|
setting_workflowimagecache_storage,
|
||||||
setting_workflowimagecache_storage_arguments
|
setting_workflowimagecache_storage_arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
storage_workflowimagecache = import_string(
|
storage_workflowimagecache = get_storage_subclass(
|
||||||
dotted_path=setting_workflowimagecache_storage.value
|
dotted_path=setting_workflowimagecache_storage.value
|
||||||
)(**setting_workflowimagecache_storage_arguments.value)
|
)(**setting_workflowimagecache_storage_arguments.value)
|
||||||
|
|||||||
22
mayan/apps/documents/migrations/0048_auto_20190711_0544.py
Normal file
22
mayan/apps/documents/migrations/0048_auto_20190711_0544.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.22 on 2019-07-11 05:44
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import mayan.apps.documents.models.document_version_models
|
||||||
|
import mayan.apps.storage.classes
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('documents', '0047_auto_20180917_0737'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='documentversion',
|
||||||
|
name='file',
|
||||||
|
field=models.FileField(storage=mayan.apps.storage.classes.FakeStorageSubclass(), upload_to=mayan.apps.documents.models.document_version_models.UUID_FUNCTION, verbose_name='File'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.utils.module_loading import import_string
|
from mayan.apps.storage.utils import get_storage_subclass
|
||||||
|
|
||||||
from .settings import (
|
from .settings import (
|
||||||
setting_documentimagecache_storage,
|
setting_documentimagecache_storage,
|
||||||
@@ -8,10 +8,10 @@ from .settings import (
|
|||||||
setting_storage_backend, setting_storage_backend_arguments
|
setting_storage_backend, setting_storage_backend_arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
storage_documentversion = import_string(
|
storage_documentversion = get_storage_subclass(
|
||||||
dotted_path=setting_storage_backend.value
|
dotted_path=setting_storage_backend.value
|
||||||
)(**setting_storage_backend_arguments.value)
|
)(**setting_storage_backend_arguments.value)
|
||||||
|
|
||||||
storage_documentimagecache = import_string(
|
storage_documentimagecache = get_storage_subclass(
|
||||||
dotted_path=setting_documentimagecache_storage.value
|
dotted_path=setting_documentimagecache_storage.value
|
||||||
)(**setting_documentimagecache_storage_arguments.value)
|
)(**setting_documentimagecache_storage_arguments.value)
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.utils.module_loading import import_string
|
from mayan.apps.storage.utils import get_storage_subclass
|
||||||
|
|
||||||
from .settings import (
|
from .settings import (
|
||||||
setting_staging_file_image_cache_storage,
|
setting_staging_file_image_cache_storage,
|
||||||
setting_staging_file_image_cache_storage_arguments,
|
setting_staging_file_image_cache_storage_arguments,
|
||||||
)
|
)
|
||||||
|
|
||||||
storage_staging_file_image_cache = import_string(
|
storage_staging_file_image_cache = get_storage_subclass(
|
||||||
dotted_path=setting_staging_file_image_cache_storage.value
|
dotted_path=setting_staging_file_image_cache_storage.value
|
||||||
)(**setting_staging_file_image_cache_storage_arguments.value)
|
)(**setting_staging_file_image_cache_storage_arguments.value)
|
||||||
|
|||||||
10
mayan/apps/storage/classes.py
Normal file
10
mayan/apps/storage/classes.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
|
||||||
|
class FakeStorageSubclass(object):
|
||||||
|
"""
|
||||||
|
Placeholder class to allow serializing the real storage subclass to
|
||||||
|
support migrations.
|
||||||
|
"""
|
||||||
|
def __eq__(self, other):
|
||||||
|
return True
|
||||||
@@ -5,6 +5,8 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
from django.utils.module_loading import import_string
|
||||||
|
|
||||||
from .settings import setting_temporary_directory
|
from .settings import setting_temporary_directory
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -39,6 +41,27 @@ def fs_cleanup(filename, file_descriptor=None, suppress_exceptions=True):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def get_storage_subclass(dotted_path):
|
||||||
|
"""
|
||||||
|
Import a storage class and return a subclass that will always return eq
|
||||||
|
True to avoid creating a new migration when for runtime storage class
|
||||||
|
changes.
|
||||||
|
"""
|
||||||
|
imported_storage_class = import_string(dotted_path=dotted_path)
|
||||||
|
|
||||||
|
class StorageSubclass(imported_storage_class):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
return super(StorageSubclass, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def deconstruct(self):
|
||||||
|
return ('mayan.apps.storage.classes.FakeStorageSubclass', (), {})
|
||||||
|
|
||||||
|
return StorageSubclass
|
||||||
|
|
||||||
|
|
||||||
def mkdtemp(*args, **kwargs):
|
def mkdtemp(*args, **kwargs):
|
||||||
kwargs.update({'dir': setting_temporary_directory.value})
|
kwargs.update({'dir': setting_temporary_directory.value})
|
||||||
return tempfile.mkdtemp(*args, **kwargs)
|
return tempfile.mkdtemp(*args, **kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user