forked from shaba/openuds
* Added "HIDDEN_FIELD" and "READ_ONLY_FIELD" to Configuration
* Added a "default" UDS Server (cluster) ID, so we can use it for a lot of things :)
This commit is contained in:
parent
b5ebd1f1fb
commit
e9d23cf170
@ -50,6 +50,7 @@ getLater = []
|
|||||||
# For custom params (for choices mainly)
|
# For custom params (for choices mainly)
|
||||||
configParams = {}
|
configParams = {}
|
||||||
|
|
||||||
|
|
||||||
class Config(object):
|
class Config(object):
|
||||||
'''
|
'''
|
||||||
Keeps persistence configuration data
|
Keeps persistence configuration data
|
||||||
@ -61,8 +62,11 @@ class Config(object):
|
|||||||
NUMERIC_FIELD = 2
|
NUMERIC_FIELD = 2
|
||||||
BOOLEAN_FIELD = 3
|
BOOLEAN_FIELD = 3
|
||||||
CHOICE_FIELD = 4 # Choice fields must set its parameters on global "configParams" (better by calling ".setParams" method)
|
CHOICE_FIELD = 4 # Choice fields must set its parameters on global "configParams" (better by calling ".setParams" method)
|
||||||
|
READ_FIELD = 5 # Only can viewed, but not changed (can be changed througn API, it's just read only to avoid "mistakes")
|
||||||
|
HIDDEN_FIELD = 6 # Not visible on "admin" config edition
|
||||||
|
|
||||||
class _Value(object):
|
class _Value(object):
|
||||||
|
|
||||||
def __init__(self, section, key, default='', crypt=False, longText=False, **kwargs):
|
def __init__(self, section, key, default='', crypt=False, longText=False, **kwargs):
|
||||||
logger.debug('Var: {} {} KWARGS: {}'.format(section, key, kwargs))
|
logger.debug('Var: {} {} KWARGS: {}'.format(section, key, kwargs))
|
||||||
self._type = kwargs.get('type', -1)
|
self._type = kwargs.get('type', -1)
|
||||||
@ -169,6 +173,7 @@ class Config(object):
|
|||||||
logger.info("Could not save configuration key {0}.{1}".format(self._section.name(), self._key))
|
logger.info("Could not save configuration key {0}.{1}".format(self._section.name(), self._key))
|
||||||
|
|
||||||
class _Section(object):
|
class _Section(object):
|
||||||
|
|
||||||
def __init__(self, sectionName):
|
def __init__(self, sectionName):
|
||||||
self._sectionName = sectionName
|
self._sectionName = sectionName
|
||||||
|
|
||||||
@ -324,6 +329,9 @@ class GlobalConfig(object):
|
|||||||
# This is used so templates can change "styles" from admin interface
|
# This is used so templates can change "styles" from admin interface
|
||||||
LOWERCASE_USERNAME = Config.section(SECURITY_SECTION).value('Convert username to lowercase', '1', type=Config.BOOLEAN_FIELD)
|
LOWERCASE_USERNAME = Config.section(SECURITY_SECTION).value('Convert username to lowercase', '1', type=Config.BOOLEAN_FIELD)
|
||||||
|
|
||||||
|
# Global UDS ID (common for all servers on the same cluster)
|
||||||
|
UDS_ID = Config.section(GLOBAL_SECTION).value('UDS ID', CryptoManager.manager().uuid(), type=Config.READ_FIELD)
|
||||||
|
|
||||||
initDone = False
|
initDone = False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -339,7 +347,6 @@ class GlobalConfig(object):
|
|||||||
|
|
||||||
GlobalConfig.UDS_THEME.setParams(themes)
|
GlobalConfig.UDS_THEME.setParams(themes)
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def initialize():
|
def initialize():
|
||||||
if GlobalConfig.initDone is False:
|
if GlobalConfig.initDone is False:
|
||||||
|
@ -36,6 +36,9 @@
|
|||||||
{{ set_var "cfg_section" key }}
|
{{ set_var "cfg_section" key }}
|
||||||
{{# eachKeySorted value }}
|
{{# eachKeySorted value }}
|
||||||
{{ set_var "cfg_key" key }}
|
{{ set_var "cfg_key" key }}
|
||||||
|
{{# ifequals value.type 6 }}
|
||||||
|
<!-- hidden -->
|
||||||
|
{{ else }}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="fld_{{ clean_whitespace ../key }}{{ key }}" class="col-sm-5 control-label">{{ key }}</label>
|
<label for="fld_{{ clean_whitespace ../key }}{{ key }}" class="col-sm-5 control-label">{{ key }}</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
@ -58,7 +61,7 @@
|
|||||||
</select>
|
</select>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<div>
|
<div>
|
||||||
<input type="{{# ifequals value.type 2 }}numeric{{ else }}text{{/ ifequals}}" class="form-control config-ctrl" data-section="{{ cfg_section }}" data-key="{{ cfg_key }}" value="{{ value.value }}">
|
<input type="{{# ifequals value.type 2 }}numeric{{ else }}text{{/ ifequals}}" {{# ifequals value.type 5 }}readonly{{/ ifequals }} class="form-control config-ctrl" data-section="{{ cfg_section }}" data-key="{{ cfg_key }}" value="{{ value.value }}">
|
||||||
</div>
|
</div>
|
||||||
{{/ ifequals }}
|
{{/ ifequals }}
|
||||||
{{/ ifequals }}
|
{{/ ifequals }}
|
||||||
@ -66,6 +69,7 @@
|
|||||||
{{/ if }}
|
{{/ if }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{/ ifequals }}
|
||||||
{{ unset_var "cfg_key" }}
|
{{ unset_var "cfg_key" }}
|
||||||
{{/ eachKeySorted }}
|
{{/ eachKeySorted }}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user