Move common.utils.return_type to the smart_settings apps where it is only used
This commit is contained in:
@@ -109,19 +109,6 @@ def pretty_size_10(size):
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
def return_type(value):
|
|
||||||
if isinstance(value, types.FunctionType):
|
|
||||||
return value.__doc__ if value.__doc__ else _('Function found')
|
|
||||||
elif isinstance(value, types.ClassType):
|
|
||||||
return '%s.%s' % (value.__class__.__module__, value.__class__.__name__)
|
|
||||||
elif isinstance(value, types.TypeType):
|
|
||||||
return '%s.%s' % (value.__module__, value.__name__)
|
|
||||||
elif isinstance(value, types.DictType) or isinstance(value, types.DictionaryType):
|
|
||||||
return ', '.join(list(value))
|
|
||||||
else:
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
def generate_choices_w_labels(choices):
|
def generate_choices_w_labels(choices):
|
||||||
results = []
|
results = []
|
||||||
for choice in choices:
|
for choice in choices:
|
||||||
|
|||||||
@@ -31,3 +31,5 @@ register_settings(
|
|||||||
{'name': 'AVAILABLE_VALIDATORS', 'global_name': 'METADATA_AVAILABLE_VALIDATORS', 'default': default_available_validators},
|
{'name': 'AVAILABLE_VALIDATORS', 'global_name': 'METADATA_AVAILABLE_VALIDATORS', 'default': default_available_validators},
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# TODO: remove classes, import by string, all settings must be simple serializable types
|
||||||
|
|||||||
16
mayan/apps/smart_settings/utils.py
Normal file
16
mayan/apps/smart_settings/utils.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import types
|
||||||
|
|
||||||
|
|
||||||
|
def return_type(value):
|
||||||
|
if isinstance(value, types.FunctionType):
|
||||||
|
return value.__doc__ if value.__doc__ else _('Function found')
|
||||||
|
elif isinstance(value, types.ClassType):
|
||||||
|
return '%s.%s' % (value.__class__.__module__, value.__class__.__name__)
|
||||||
|
elif isinstance(value, types.TypeType):
|
||||||
|
return '%s.%s' % (value.__module__, value.__name__)
|
||||||
|
elif isinstance(value, types.DictType) or isinstance(value, types.DictionaryType):
|
||||||
|
return ', '.join(list(value))
|
||||||
|
else:
|
||||||
|
return value
|
||||||
@@ -5,10 +5,11 @@ from django.template import RequestContext
|
|||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
from common.utils import encapsulate, return_type
|
from common.utils import encapsulate
|
||||||
from common.widgets import exists_widget
|
from common.widgets import exists_widget
|
||||||
|
|
||||||
from .api import settings
|
from .api import settings
|
||||||
|
from .utils import return_type # TODO: remove return_type, all settings must be simple types
|
||||||
|
|
||||||
|
|
||||||
def setting_list(request):
|
def setting_list(request):
|
||||||
|
|||||||
Reference in New Issue
Block a user