Further decouple document file storage from file based storage

This commit is contained in:
Roberto Rosario
2011-03-03 21:16:39 -04:00
parent a61dbcb7ca
commit fc87e3a097
4 changed files with 3 additions and 12 deletions

View File

@@ -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')

View File

@@ -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'))

View File

@@ -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'

View File

@@ -194,7 +194,6 @@ LOGIN_EXEMPT_URLS = (
#DOCUMENTS_DEFAULT_TRANSFORMATIONS = []
# Storage
#DOCUMENTS_STORAGE_DIRECTORY_NAME = 'documents'
#DOCUMENTS_STORAGE_BACKEND = DocumentStorage
# Usage