Merge branch 'feature/tabbed_settings' into development
This commit is contained in:
@@ -8,7 +8,7 @@ from django.conf import settings
|
||||
|
||||
from smart_settings.api import Setting, SettingNamespace
|
||||
|
||||
namespace = SettingNamespace('django_gpg', _(u'Signatures'), module='django_gpg.conf.settings')
|
||||
namespace = SettingNamespace('django_gpg', _(u'Signatures'), module='django_gpg.conf.settings', sprite='text_signature')
|
||||
|
||||
Setting(
|
||||
namespace=namespace,
|
||||
|
||||
@@ -9,7 +9,7 @@ available_indexing_functions = {
|
||||
'proper_name': proper_name
|
||||
}
|
||||
|
||||
namespace = SettingNamespace('document_indexing', _(u'Indexing'), module='document_indexing.conf.settings')
|
||||
namespace = SettingNamespace('document_indexing', _(u'Indexing'), module='document_indexing.conf.settings', sprite='tab')
|
||||
|
||||
# Definition
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ def default_uuid():
|
||||
return unicode(uuid.uuid4())
|
||||
|
||||
|
||||
namespace = SettingNamespace('documents', _(u'Documents'), module='documents.conf.settings')
|
||||
namespace = SettingNamespace('documents', _(u'Documents'), module='documents.conf.settings', sprite='page')
|
||||
|
||||
# Saving
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from smart_settings.api import Setting, SettingNamespace
|
||||
|
||||
namespace = SettingNamespace('dynamic_search', _(u'Searching'), module='dynamic_search.conf.settings')
|
||||
namespace = SettingNamespace('dynamic_search', _(u'Searching'), module='dynamic_search.conf.settings', sprite='zoom')
|
||||
|
||||
Setting(
|
||||
namespace=namespace,
|
||||
|
||||
@@ -4,7 +4,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from smart_settings.api import Setting, SettingNamespace
|
||||
|
||||
namespace = SettingNamespace('linking', _(u'Linking'), module='linking.conf.settings')
|
||||
namespace = SettingNamespace('linking', _(u'Linking'), module='linking.conf.settings', sprite='link')
|
||||
|
||||
Setting(
|
||||
namespace=namespace,
|
||||
|
||||
@@ -15,7 +15,7 @@ default_available_models = {
|
||||
'User': User
|
||||
}
|
||||
|
||||
namespace = SettingNamespace('metadata', _(u'Metadata'), module='metadata.conf.settings')
|
||||
namespace = SettingNamespace('metadata', _(u'Metadata'), module='metadata.conf.settings', sprite='xhtml')
|
||||
|
||||
Setting(
|
||||
namespace=namespace,
|
||||
|
||||
@@ -4,7 +4,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from smart_settings.api import Setting, SettingNamespace
|
||||
|
||||
namespace = SettingNamespace('ocr', _(u'OCR'), module='ocr.conf.settings')
|
||||
namespace = SettingNamespace('ocr', _(u'OCR'), module='ocr.conf.settings', sprite='spellcheck')
|
||||
|
||||
Setting(
|
||||
namespace=namespace,
|
||||
|
||||
@@ -3,7 +3,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from smart_settings.api import Setting, SettingNamespace
|
||||
|
||||
namespace = SettingNamespace('permissions', _(u'Permissions'), module='permissions.conf.settings')
|
||||
namespace = SettingNamespace('permissions', _(u'Permissions'), module='permissions.conf.settings', sprite='key')
|
||||
|
||||
Setting(
|
||||
namespace=namespace,
|
||||
|
||||
@@ -5,6 +5,7 @@ from django.utils.importlib import import_module
|
||||
|
||||
settings = {}
|
||||
settings_list = []
|
||||
namespaces = {}
|
||||
namespace_list = []
|
||||
|
||||
|
||||
@@ -13,11 +14,13 @@ def is_superuser(context):
|
||||
|
||||
|
||||
class SettingNamespace(object):
|
||||
def __init__(self, name, label, module):
|
||||
def __init__(self, name, label, module, sprite=None):
|
||||
self.name = name
|
||||
self.label = label
|
||||
self.module = module
|
||||
self.sprite = sprite
|
||||
namespace_list.append(self)
|
||||
namespaces[self.name] = self
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.label)
|
||||
@@ -48,3 +51,5 @@ class Setting(object):
|
||||
setattr(self.module, name, value)
|
||||
|
||||
settings_list.append(self)
|
||||
settings.setdefault(self.namespace.name, [])
|
||||
settings[self.namespace.name].append(self)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from django.conf.urls.defaults import patterns, url
|
||||
|
||||
urlpatterns = patterns('smart_settings.views',
|
||||
url(r'^list/(?P<namespace_name>\w+)/$', 'setting_list', (), 'setting_list'),
|
||||
url(r'^list/$', 'setting_list', (), 'setting_list'),
|
||||
)
|
||||
|
||||
@@ -7,14 +7,27 @@ from django.utils.safestring import mark_safe
|
||||
|
||||
from common.utils import return_type, encapsulate
|
||||
from common.widgets import exists_with_famfam
|
||||
from navigation.api import Link
|
||||
|
||||
from .api import settings_list
|
||||
from .api import settings_list, namespace_list, settings, namespaces
|
||||
from .links import is_superuser
|
||||
|
||||
|
||||
def setting_list(request):
|
||||
def setting_list(request, namespace_name=None, object_list=None, title=None, extra_context=None):
|
||||
#TODO: check user is super user
|
||||
namespace_links = []
|
||||
for namespace in namespace_list:
|
||||
namespace_links.append(
|
||||
Link(text=namespace.label, view='setting_list', args=[u'"%s"' % namespace.name], sprite=getattr(namespace, 'sprite') or 'cog', condition=is_superuser, children_view_regex=[r'^setting_'])
|
||||
)
|
||||
|
||||
if namespace_name:
|
||||
object_list = [setting for setting in settings[namespace_name] if setting.hidden == False]
|
||||
title = _(u'settings for the %s module') % namespaces[namespace_name]
|
||||
|
||||
context = {
|
||||
'title': _(u'settings'),
|
||||
'object_list': [setting for setting in settings_list if setting.hidden == False],
|
||||
'title': title if title else _(u'settings'),
|
||||
'object_list': object_list if not (object_list is None) else [setting for setting in settings_list if setting.hidden == False],
|
||||
'hide_link': True,
|
||||
'hide_object': True,
|
||||
'extra_columns': [
|
||||
@@ -26,7 +39,17 @@ def setting_list(request):
|
||||
)))
|
||||
},
|
||||
],
|
||||
'temporary_navigation_links': {
|
||||
'form_header': {
|
||||
'setting_list': {
|
||||
'links': namespace_links
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if extra_context:
|
||||
context.update(extra_context)
|
||||
|
||||
return render_to_response('generic_list.html', context,
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
Reference in New Issue
Block a user