Module: check_mk
Branch: master
Commit: 6fa02af81f3c6e0b41334d7b89bf16ba018de3ed
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6fa02af81f3c6e…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jun 1 08:07:49 2012 +0200
WATO: more save resetting of config variables
---
web/htdocs/wato.py | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index ef18a6d..567e75c 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -5191,7 +5191,7 @@ def mode_globalvars(phase):
varname = html.var("_varname")
action = html.var("_action")
if varname:
- domain, valuespec, need_restart = g_configvars[varname]
+ domain, valuespec, need_restart, allow_reset = g_configvars[varname]
def_value = default_values.get(varname, valuespec.canonical_value())
if action == "reset" and not isinstance(valuespec, Checkbox):
@@ -5288,12 +5288,22 @@ def mode_edit_configvar(phase):
return
varname = html.var("varname")
- domain, valuespec, need_restart = g_configvars[varname]
+ domain, valuespec, need_restart, allow_reset = g_configvars[varname]
current_settings = load_configuration_settings()
is_on_default = varname not in current_settings
if phase == "action":
if html.var("reset"):
+ if not isinstance(valuespec, Checkbox):
+ c = wato_confirm(
+ _("Resetting configuration variable"),
+ _("Do you really want to reset this configuration variable
"
+ "back to its default value?"))
+ if c == False:
+ return ""
+ elif c == None:
+ return None
+
del current_settings[varname]
msg = _("Resetted configuration variable %s to its default.") %
varname
else:
@@ -5345,7 +5355,7 @@ def mode_edit_configvar(phase):
forms.end()
html.button("save", _("Save"))
- if not is_on_default:
+ if allow_reset and not is_on_default:
curvalue = current_settings[varname]
html.button("reset", curvalue == defvalue and _("Remove explicit
setting") or _("Reset to default"))
html.hidden_fields()
@@ -5355,9 +5365,9 @@ g_configvars = {}
g_configvar_groups = {}
# domain is one of "check_mk", "multisite" or "nagios"
-def register_configvar(group, varname, valuespec, domain="check_mk",
need_restart=False):
+def register_configvar(group, varname, valuespec, domain="check_mk",
need_restart=False, allow_reset=True):
g_configvar_groups.setdefault(group, []).append((domain, varname, valuespec))
- g_configvars[varname] = domain, valuespec, need_restart
+ g_configvars[varname] = domain, valuespec, need_restart, allow_reset
g_configvar_domains = {
"check_mk" : {
@@ -5416,7 +5426,7 @@ def load_configuration_vars(filename, settings):
def save_configuration_settings(vars):
per_domain = {}
- for varname, (domain, valuespec, need_restart) in g_configvars.items():
+ for varname, (domain, valuespec, need_restart, allow_reset) in g_configvars.items():
if varname not in vars:
continue
per_domain.setdefault(domain, {})[varname] = vars[varname]