diff --git a/mayan/apps/smart_settings/classes.py b/mayan/apps/smart_settings/classes.py index d22764e5ef..86e764e18c 100644 --- a/mayan/apps/smart_settings/classes.py +++ b/mayan/apps/smart_settings/classes.py @@ -64,6 +64,8 @@ class Namespace(object): class Setting(object): + _registry = {} + @staticmethod def deserialize_value(value): return yaml.safe_load(value) @@ -75,12 +77,17 @@ class Setting(object): return yaml.safe_dump(value, allow_unicode=True) + @classmethod + def get(cls, global_name): + return cls._registry[global_name].value + def __init__(self, namespace, global_name, default, help_text=None, is_path=False): self.global_name = global_name self.default = default self.help_text = help_text self.loaded = False namespace.settings.append(self) + self.__class__._registry[global_name] = self def __unicode__(self): return unicode(self.global_name) diff --git a/mayan/apps/smart_settings/templatetags/__init__.py b/mayan/apps/smart_settings/templatetags/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/mayan/apps/smart_settings/templatetags/smart_settings_tags.py b/mayan/apps/smart_settings/templatetags/smart_settings_tags.py new file mode 100644 index 0000000000..34c8975a1d --- /dev/null +++ b/mayan/apps/smart_settings/templatetags/smart_settings_tags.py @@ -0,0 +1,12 @@ +from __future__ import unicode_literals + +from django.template import Library + +from ..classes import Setting + +register = Library() + + +@register.simple_tag +def smart_setting(global_name): + return Setting.get(global_name=global_name)