Module: check_mk
Branch: master
Commit: 1b7a2ef34b3b921bd4cf9c50b6eb814962c5f484
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1b7a2ef34b3b92…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Jul 30 17:03:57 2013 +0200
edit_form: new preview mode
---
web/htdocs/forms.py | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/web/htdocs/forms.py b/web/htdocs/forms.py
index 91873ee..78d90ac 100644
--- a/web/htdocs/forms.py
+++ b/web/htdocs/forms.py
@@ -40,11 +40,17 @@ def get_input(valuespec, varprefix):
return value
+
+# preview = True: Do not output error messages, do not consume
+# current transaction. This is for preview mode
def edit_dictionary(entries, value, focus=None, hover_help=True,
validate=None, buttontext=None, title=None,
- buttons = None, method="GET"):
+ buttons = None, method="GET", preview=False):
new_value = value.copy()
- if html.var("filled_in") == "form" and html.check_transaction():
+ if html.var("filled_in") == "form" and html.transaction_valid():
+ if not preview:
+ html.check_transaction()
+
messages = []
for name, vs in entries:
try:
@@ -63,10 +69,14 @@ def edit_dictionary(entries, value, focus=None, hover_help=True,
html.add_user_error(e.varname, e.message)
if messages:
- html.show_error("".join(["%s<br>\n" % m for m in
messages]))
+ if not preview:
+ html.show_error("".join(["%s<br>\n" % m for m
in messages]))
+ else:
+ return None
else:
return new_value
+
html.begin_form("form", method=method)
header(title and title or _("Properties"))
first = True