Update the storage app to assign itself and icon and register with the app registry

This commit is contained in:
Roberto Rosario
2012-09-08 03:25:49 -04:00
parent fd54e9c9d9
commit 9ef2bfc165
10 changed files with 118 additions and 106 deletions
+1
View File
@@ -35,6 +35,7 @@ PILL = 'pill'
PLUGIN = 'plugin'
RAINBOW = 'rainbow'
SCRIPT = 'script'
STORAGE = 'storage'
TABLE = 'table'
TICK = 'tick'
USER = 'user'
+1
View File
@@ -37,6 +37,7 @@ DICTIONARY = {
PLUGIN: 'plugin.png',
RAINBOW: 'rainbow.png',
SCRIPT: 'script.png',
STORAGE: 'storage.png',
TABLE: 'table.png',
TICK: 'tick.png',
USER: 'user.png',
+1
View File
@@ -0,0 +1 @@
+4 -3
View File
@@ -2,12 +2,13 @@ import os
from django.core.files.storage import FileSystemStorage
from storage.conf.settings import FILESTORAGE_LOCATION
from storage import FILESTORAGE_LOCATION
class FileBasedStorage(FileSystemStorage):
'''Simple wrapper for the stock Django FileSystemStorage class
'''
"""
Simple wrapper for the stock Django FileSystemStorage class
"""
separator = os.path.sep
def __init__(self, *args, **kwargs):
View File
-38
View File
@@ -1,38 +0,0 @@
"""Configuration options for the storage app"""
import os
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from smart_settings.api import Setting, SettingNamespace
namespace = SettingNamespace('storage', _(u'Storage'), module='storage.conf.settings')
Setting(
namespace=namespace,
name='GRIDFS_HOST',
global_name='STORAGE_GRIDFS_HOST',
default=u'localhost',
)
Setting(
namespace=namespace,
name='GRIDFS_PORT',
global_name='STORAGE_GRIDFS_PORT',
default=27017,
)
Setting(
namespace=namespace,
name='GRIDFS_DATABASE_NAME',
global_name='STORAGE_GRIDFS_DATABASE_NAME',
default='document_storage',
)
Setting(
namespace=namespace,
name='FILESTORAGE_LOCATION',
global_name='STORAGE_FILESTORAGE_LOCATION',
default=os.path.join(settings.PROJECT_ROOT, u'document_storage'),
exists=True
)
+7
View File
@@ -0,0 +1,7 @@
from __future__ import absolute_import
from icons.literals import STORAGE
from icons import Icon
icon_storage = Icon(STORAGE)
+39
View File
@@ -0,0 +1,39 @@
from __future__ import absolute_import
import os
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
from smart_settings import LocalScope
from .icons import icon_storage
name = 'storage'
label = _(u'Storage')
description = _(u'Handles actual storage of files by means of specialized backends.')
icon = icon_storage
dependencies = ['app_registry']
settings = [
{
'name': 'GRIDFS_HOST',
'default': u'localhost',
'scopes': [LocalScope()]
},
{
'name': 'GRIDFS_PORT',
'default': 27017,
'scopes': [LocalScope()]
},
{
'name': 'GRIDFS_DATABASE_NAME',
'default': 'document_storage',
'scopes': [LocalScope()]
},
{
'name': 'FILESTORAGE_LOCATION',
'default': os.path.join(settings.PROJECT_ROOT, u'document_storage'),
'exists': True,
'scopes': [LocalScope()]
},
]