diff --git a/apps/documents/conf/settings.py b/apps/documents/conf/settings.py index 064ecc0aa4..6799404870 100755 --- a/apps/documents/conf/settings.py +++ b/apps/documents/conf/settings.py @@ -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') diff --git a/apps/storage/__init__.py b/apps/storage/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/apps/storage/backends/__init__.py b/apps/storage/backends/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/apps/documents/storage.py b/apps/storage/backends/filebasedstorage.py similarity index 56% rename from apps/documents/storage.py rename to apps/storage/backends/filebasedstorage.py index 2567a00d06..7baca016a8 100755 --- a/apps/documents/storage.py +++ b/apps/storage/backends/filebasedstorage.py @@ -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' diff --git a/apps/storage/models.py b/apps/storage/models.py new file mode 100644 index 0000000000..71a8362390 --- /dev/null +++ b/apps/storage/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/apps/storage/tests.py b/apps/storage/tests.py new file mode 100644 index 0000000000..2247054b35 --- /dev/null +++ b/apps/storage/tests.py @@ -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 +"""} + diff --git a/apps/storage/views.py b/apps/storage/views.py new file mode 100644 index 0000000000..60f00ef0ef --- /dev/null +++ b/apps/storage/views.py @@ -0,0 +1 @@ +# Create your views here. diff --git a/settings.py b/settings.py index 6f43445114..fac4adf3b5 100755 --- a/settings.py +++ b/settings.py @@ -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'