Module: check_mk
Branch: master
Commit: 933abd6304395e0e2d423dd7fa7eb1b34296e311
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=933abd6304395e…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 5 09:53:10 2018 +0100
Moved view specific limit function to views module
Change-Id: Id154aebd86b102cc3748c3d811bf9bd127e9f581
---
web/htdocs/bi.py | 4 ++--
web/htdocs/html_mod_python.py | 17 -----------------
web/htdocs/mobile.py | 3 +--
web/htdocs/views.py | 19 ++++++++++++++++++-
4 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 4b1b786..389aa80 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -3432,7 +3432,7 @@ def table(columns, add_headers, only_sites, limit, filters):
row["aggr_group"] = group
rows.append(row)
- if not html.check_limit(rows, limit):
+ if not views.check_limit(rows, limit):
return rows
return rows
@@ -3573,7 +3573,7 @@ def singlehost_table(columns, add_headers, only_sites, limit,
filters, joinbynam
row.update(new_row)
row["aggr_group"] = group
rows.append(row)
- if not html.check_limit(rows, limit):
+ if not views.check_limit(rows, limit):
return rows
diff --git a/web/htdocs/html_mod_python.py b/web/htdocs/html_mod_python.py
index 5baae11..b69cced 100644
--- a/web/htdocs/html_mod_python.py
+++ b/web/htdocs/html_mod_python.py
@@ -251,23 +251,6 @@ class html_mod_python(htmllib.html):
def set_content_type(self, ty):
self.req.content_type = ty
- def check_limit(self, rows, limit):
- count = len(rows)
- if limit != None and count >= limit + 1:
- text = _("Your query produced more than %d results. ") % limit
- if self.var("limit", "soft") == "soft" and
config.user.may("general.ignore_soft_limit"):
- text += '<a href="%s">%s</a>' % \
- (self.makeuri([("limit", "hard")]),
_('Repeat query and allow more results.'))
- elif self.var("limit") == "hard" and
config.user.may("general.ignore_hard_limit"):
- text += '<a href="%s">%s</a>' % \
- (self.makeuri([("limit", "none")]),
_('Repeat query without limit.'))
- text += " " + _("<b>Note:</b> the shown results
are incomplete and do not reflect the sort order.")
- self.show_warning(text)
- del rows[limit:]
- return False
- return True
-
-
def load_transids(self, lock = False):
return config.user.load_file("transids", [], lock)
diff --git a/web/htdocs/mobile.py b/web/htdocs/mobile.py
index 30923c5..9d21d32 100644
--- a/web/htdocs/mobile.py
+++ b/web/htdocs/mobile.py
@@ -312,8 +312,7 @@ def render_view(view, rows, datasource, group_painters, painters,
html.write(_("No hosts/services found."))
else:
try:
- # TODO: special limit for mobile UI
- html.check_limit(rows, views.get_limit())
+ views.check_limit(rows, views.get_limit())
layout["render"](rows, view, group_painters, painters,
num_columns,
show_checkboxes and not html.do_actions())
except Exception, e:
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 29c9b4f..7c04406 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1898,7 +1898,7 @@ def render_view(view, rows, datasource, group_painters, painters,
if not has_done_actions:
# Limit exceeded? Show warning
if display_options.enabled(display_options.W):
- html.check_limit(rows, get_limit())
+ check_limit(rows, get_limit())
layout["render"](rows, view, group_painters, painters, num_columns,
show_checkboxes and not html.do_actions())
headinfo = "%d %s" % (row_count, _("row") if row_count == 1
else _("rows"))
@@ -1961,6 +1961,23 @@ def render_view(view, rows, datasource, group_painters, painters,
html.body_end()
+def check_limit(rows, limit):
+ count = len(rows)
+ if limit != None and count >= limit + 1:
+ text = _("Your query produced more than %d results. ") % limit
+ if html.var("limit", "soft") == "soft" and
config.user.may("general.ignore_soft_limit"):
+ text += '<a href="%s">%s</a>' % \
+ (html.makeuri([("limit", "hard")]),
_('Repeat query and allow more results.'))
+ elif html.var("limit") == "hard" and
config.user.may("general.ignore_hard_limit"):
+ text += '<a href="%s">%s</a>' % \
+ (html.makeuri([("limit", "none")]),
_('Repeat query without limit.'))
+ text += " " + _("<b>Note:</b> the shown results are
incomplete and do not reflect the sort order.")
+ html.show_warning(text)
+ del rows[limit:]
+ return False
+ return True
+
+
def do_table_join(master_ds, master_rows, master_filters, join_cells, join_columns,
only_sites):
join_table, join_master_column = master_ds["join"]
slave_ds = multisite_datasources[join_table]