From 09f7cc1a5b0d219fb16455333e2e90001f91db7e Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 7 Apr 2015 16:36:42 -0400 Subject: [PATCH] Move common.utils.return_type to the smart_settings apps where it is only used --- mayan/apps/common/utils.py | 13 ------------- mayan/apps/metadata/settings.py | 2 ++ mayan/apps/smart_settings/utils.py | 16 ++++++++++++++++ mayan/apps/smart_settings/views.py | 3 ++- 4 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 mayan/apps/smart_settings/utils.py diff --git a/mayan/apps/common/utils.py b/mayan/apps/common/utils.py index 2bd5807a66..e483651420 100644 --- a/mayan/apps/common/utils.py +++ b/mayan/apps/common/utils.py @@ -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): results = [] for choice in choices: diff --git a/mayan/apps/metadata/settings.py b/mayan/apps/metadata/settings.py index 0ca8c1709b..a06bc26eea 100644 --- a/mayan/apps/metadata/settings.py +++ b/mayan/apps/metadata/settings.py @@ -31,3 +31,5 @@ register_settings( {'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 diff --git a/mayan/apps/smart_settings/utils.py b/mayan/apps/smart_settings/utils.py new file mode 100644 index 0000000000..33056e8945 --- /dev/null +++ b/mayan/apps/smart_settings/utils.py @@ -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 diff --git a/mayan/apps/smart_settings/views.py b/mayan/apps/smart_settings/views.py index 6714b12815..8fee01e6ae 100644 --- a/mayan/apps/smart_settings/views.py +++ b/mayan/apps/smart_settings/views.py @@ -5,10 +5,11 @@ from django.template import RequestContext from django.utils.translation import ugettext_lazy as _ 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 .api import settings +from .utils import return_type # TODO: remove return_type, all settings must be simple types def setting_list(request):