Module: check_mk
Branch: master
Commit: 9577eb61fa6b0c4720e9c662283cf4968cd3f7d6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9577eb61fa6b0c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Oct 5 17:18:59 2017 +0200
htmllib: added render_{error,warning,info} methods
Change-Id: I29bda3b61c046e25e9ddcc07a573709e67cdda6d
---
web/htdocs/htmllib.py | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 0364e18..d9c8e79 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -1672,8 +1672,24 @@ class html(HTMLGenerator, RequestHandler):
self.message(msg, 'warning')
- # obj might be either a string (str or unicode) or an exception object
+ def render_info(self, msg):
+ return self.render_message(msg, 'message')
+
+
+ def render_error(self, msg):
+ return self.render_message(msg, 'error')
+
+
+ def render_warning(self, msg):
+ return self.render_message(msg, 'warning')
+
+
def message(self, msg, what='message'):
+ self.write(self.render_message(msg, what))
+
+
+ # obj might be either a string (str or unicode) or an exception object
+ def render_message(self, msg, what='message'):
if what == 'message':
cls = 'success'
prefix = _('MESSAGE')
@@ -1684,18 +1700,16 @@ class html(HTMLGenerator, RequestHandler):
cls = 'error'
prefix = _('ERROR')
+ code = ""
+
if self.output_format == "html":
+ code += self.render_div(self.render_text(msg), class_=cls)
if self.mobile:
- self.open_center()
- self.open_div(class_=cls)
- self.write_text(msg)
- self.close_div()
- if self.mobile:
- self.close_center()
+ code += self.render_center(code)
else:
- self.write_text('%s: %s\n' % (prefix, self.strip_tags(msg)))
+ code += self.render_text('%s: %s\n' % (prefix,
self.strip_tags(msg)))
- #self.guitest_record_output("message", (what, msg))
+ return code
def show_localization_hint(self):