Further decouple document file storage from file based storage
This commit is contained in:
@@ -45,7 +45,6 @@ PAGE_COUNT_FUNCTION = getattr(settings, 'DOCUMENTS_PAGE_COUNT_FUNCTION', lambda
|
||||
|
||||
# Storage
|
||||
STORAGE_BACKEND = getattr(settings, 'DOCUMENTS_STORAGE_BACKEND', DocumentStorage)
|
||||
STORAGE_DIRECTORY_NAME = getattr(settings, 'DOCUMENTS_STORAGE_DIRECTORY_NAME', 'documents')
|
||||
|
||||
# Usage
|
||||
PREVIEW_SIZE = getattr(settings, 'DOCUMENTS_PREVIEW_SIZE', '640x480')
|
||||
|
||||
@@ -16,23 +16,17 @@ from documents.conf.settings import CHECKSUM_FUNCTION
|
||||
from documents.conf.settings import UUID_FUNCTION
|
||||
from documents.conf.settings import PAGE_COUNT_FUNCTION
|
||||
from documents.conf.settings import STORAGE_BACKEND
|
||||
from documents.conf.settings import STORAGE_DIRECTORY_NAME
|
||||
from documents.conf.settings import AVAILABLE_TRANSFORMATIONS
|
||||
from documents.conf.settings import DEFAULT_TRANSFORMATIONS
|
||||
|
||||
|
||||
|
||||
def get_filename_from_uuid(instance, filename, directory=STORAGE_DIRECTORY_NAME):
|
||||
populate_file_extension_and_mimetype(instance, filename)
|
||||
return '%s/%s' % (directory, instance.uuid)
|
||||
|
||||
def populate_file_extension_and_mimetype(instance, filename):
|
||||
# First populate the file extension
|
||||
def get_filename_from_uuid(instance, filename):
|
||||
filename, extension = os.path.splitext(filename)
|
||||
instance.file_filename = filename
|
||||
#remove prefix '.'
|
||||
instance.file_extension = extension[1:]
|
||||
|
||||
return instance.uuid
|
||||
|
||||
|
||||
class DocumentType(models.Model):
|
||||
name = models.CharField(max_length=32, verbose_name=_(u'name'))
|
||||
|
||||
@@ -4,5 +4,4 @@ class DocumentStorage(FileSystemStorage):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(DocumentStorage, self).__init__(*args, **kwargs)
|
||||
self.location='document_storage'
|
||||
self.base_url='document_storage'
|
||||
|
||||
|
||||
@@ -194,7 +194,6 @@ LOGIN_EXEMPT_URLS = (
|
||||
#DOCUMENTS_DEFAULT_TRANSFORMATIONS = []
|
||||
|
||||
# Storage
|
||||
#DOCUMENTS_STORAGE_DIRECTORY_NAME = 'documents'
|
||||
#DOCUMENTS_STORAGE_BACKEND = DocumentStorage
|
||||
|
||||
# Usage
|
||||
|
||||
Reference in New Issue
Block a user