Remove use of storage wrappers

Use a dynamic subclass instead that always deconstructs to a fake
subclass with a __eq__ method that always returns True. This should
trick makemigrations into never creating a new migrations for
changes to the storage class or the arguments.

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2018-12-29 03:41:47 -04:00
parent 442bf5dc4b
commit 000fe87c37
11 changed files with 59 additions and 35 deletions

View File

@@ -21,7 +21,7 @@ from ..literals import DOCUMENT_IMAGES_CACHE_NAME
from ..managers import DocumentVersionManager
from ..settings import setting_fix_orientation
from ..signals import post_document_created, post_version_upload
from ..storages import storage_documentversion_wrapper
from ..storages import storage_documentversion
from ..utils import document_hash_function, document_uuid_function
from .document_models import Document
@@ -67,7 +67,7 @@ class DocumentVersion(models.Model):
# File related fields
file = models.FileField(
storage=storage_documentversion_wrapper, upload_to=document_uuid_function,
storage=storage_documentversion, upload_to=document_uuid_function,
verbose_name=_('File')
)
mimetype = models.CharField(
@@ -137,7 +137,7 @@ class DocumentVersion(models.Model):
be in the document storage. This is a diagnostic flag to help users
detect if the storage has desynchronized (ie: Amazon's S3).
"""
return self.file.storage().exists(self.file.name)
return self.file.storage.exists(self.file.name)
def fix_orientation(self):
for page in self.pages.all():
@@ -329,7 +329,7 @@ class DocumentVersion(models.Model):
@property
def size(self):
if self.exists():
return self.file.storage().size(self.file.name)
return self.file.storage.size(self.file.name)
else:
return None