Finally abstract storage to its own app
This commit is contained in:
@@ -9,7 +9,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from converter.api import get_page_count
|
||||
|
||||
from documents.storage import DocumentStorage
|
||||
from storage.backends.filebasedstorage import FileBasedStorage
|
||||
|
||||
default_available_functions = {
|
||||
'current_date':datetime.datetime.now().date,
|
||||
@@ -23,7 +23,6 @@ available_transformations = {
|
||||
'rotate': {'label':_(u'Rotate [degrees]'), 'arguments':[{'name':'degrees'}]}
|
||||
}
|
||||
|
||||
|
||||
# Definition
|
||||
AVAILABLE_FUNCTIONS = getattr(settings, 'DOCUMENTS_METADATA_AVAILABLE_FUNCTIONS', default_available_functions)
|
||||
AVAILABLE_MODELS = getattr(settings, 'DOCUMENTS_METADATA_AVAILABLE_MODELS', default_available_models)
|
||||
@@ -44,7 +43,7 @@ UUID_FUNCTION = getattr(settings, 'DOCUMENTS_UUID_FUNCTION', lambda:unicode(uuid
|
||||
PAGE_COUNT_FUNCTION = getattr(settings, 'DOCUMENTS_PAGE_COUNT_FUNCTION', lambda x: get_page_count(x.save_to_file(tempfile.mkstemp()[1])))
|
||||
|
||||
# Storage
|
||||
STORAGE_BACKEND = getattr(settings, 'DOCUMENTS_STORAGE_BACKEND', DocumentStorage)
|
||||
STORAGE_BACKEND = getattr(settings, 'DOCUMENTS_STORAGE_BACKEND', FileBasedStorage)
|
||||
|
||||
# Usage
|
||||
PREVIEW_SIZE = getattr(settings, 'DOCUMENTS_PREVIEW_SIZE', '640x480')
|
||||
|
||||
0
apps/storage/__init__.py
Normal file
0
apps/storage/__init__.py
Normal file
0
apps/storage/backends/__init__.py
Normal file
0
apps/storage/backends/__init__.py
Normal file
@@ -1,7 +1,7 @@
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
|
||||
class DocumentStorage(FileSystemStorage):
|
||||
class FileBasedStorage(FileSystemStorage):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(DocumentStorage, self).__init__(*args, **kwargs)
|
||||
super(FileBasedStorage, self).__init__(*args, **kwargs)
|
||||
self.location='document_storage'
|
||||
|
||||
3
apps/storage/models.py
Normal file
3
apps/storage/models.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
23
apps/storage/tests.py
Normal file
23
apps/storage/tests.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""
|
||||
This file demonstrates two different styles of tests (one doctest and one
|
||||
unittest). These will both pass when you run "manage.py test".
|
||||
|
||||
Replace these with more appropriate tests for your application.
|
||||
"""
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.failUnlessEqual(1 + 1, 2)
|
||||
|
||||
__test__ = {"doctest": """
|
||||
Another way to test that 1 + 1 is equal to 2.
|
||||
|
||||
>>> 1 + 1 == 2
|
||||
True
|
||||
"""}
|
||||
|
||||
1
apps/storage/views.py
Normal file
1
apps/storage/views.py
Normal file
@@ -0,0 +1 @@
|
||||
# Create your views here.
|
||||
@@ -132,7 +132,7 @@ INSTALLED_APPS = (
|
||||
'sentry.client',
|
||||
'sentry.client.celery',
|
||||
'filesystem_serving',
|
||||
|
||||
'storage',
|
||||
)
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
@@ -194,7 +194,7 @@ LOGIN_EXEMPT_URLS = (
|
||||
#DOCUMENTS_DEFAULT_TRANSFORMATIONS = []
|
||||
|
||||
# Storage
|
||||
#DOCUMENTS_STORAGE_BACKEND = DocumentStorage
|
||||
#DOCUMENTS_STORAGE_BACKEND = FileBasedStorage
|
||||
|
||||
# Usage
|
||||
#DOCUMENTS_PREVIEW_SIZE = '640x480'
|
||||
|
||||
Reference in New Issue
Block a user