Module: check_mk
Branch: master
Commit: 2cb7f9a1d54645e25461970907a471172b32ab92
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2cb7f9a1d54645…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri May 29 09:18:33 2015 +0200
Fix CSV export of new matrix layout when uniform rows are omitted
---
web/htdocs/views.py | 47 +++++++++++++++++++++---------------------
web/plugins/views/layouts.py | 1 +
2 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index c966f2e..6181f53 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -1057,28 +1057,6 @@ def show_view(view, show_heading = False, show_buttons = True,
colset.remove("site")
columns = list(colset)
- # The layout of the view: it can be overridden by several specifying
- # an output format (like json or python). Note: the layout is not
- # always needed. In case of an embedded view in the reporting this
- # field is simply missing, because the rendering is done by the
- # report itself.
- # TODO: CSV export should be handled by the layouts. It cannot
- # be done generic in most cases
- if html.output_format == "html":
- if "layout" in view:
- layout = multisite_layouts[view["layout"]]
- else:
- layout = None
- else:
- if "layout" in view and "csv_export" in
multisite_layouts[view["layout"]]:
- multisite_layouts[view["layout"]]["csv_export"](rows,
view, group_painters, painters)
- return
- else:
- # Generic layout of export
- layout = multisite_layouts.get(html.output_format)
- if not layout:
- layout = multisite_layouts["json"]
-
# Get list of painter options we need to display (such as PNP time range
# or the format being used for timestamp display)
painter_options = []
@@ -1089,7 +1067,8 @@ def show_view(view, show_heading = False, show_buttons = True,
need_inventory_data = True
# Also layouts can register painter options
- painter_options += layout.get("options", [])
+ if "layout" in view:
+ painter_options +=
multisite_layouts[view["layout"]].get("options", [])
painter_options = list(set(painter_options))
painter_options.sort()
@@ -1136,6 +1115,28 @@ def show_view(view, show_heading = False, show_buttons = True,
html.del_var(varname)
return len(rows)
+ # The layout of the view: it can be overridden by several specifying
+ # an output format (like json or python). Note: the layout is not
+ # always needed. In case of an embedded view in the reporting this
+ # field is simply missing, because the rendering is done by the
+ # report itself.
+ # TODO: CSV export should be handled by the layouts. It cannot
+ # be done generic in most cases
+ if html.output_format == "html":
+ if "layout" in view:
+ layout = multisite_layouts[view["layout"]]
+ else:
+ layout = None
+ else:
+ if "layout" in view and "csv_export" in
multisite_layouts[view["layout"]]:
+ multisite_layouts[view["layout"]]["csv_export"](rows,
view, group_painters, painters)
+ return
+ else:
+ # Generic layout of export
+ layout = multisite_layouts.get(html.output_format)
+ if not layout:
+ layout = multisite_layouts["json"]
+
# Set browser reload
if browser_reload and 'R' in display_options and not only_count:
html.set_browser_reload(browser_reload)
diff --git a/web/plugins/views/layouts.py b/web/plugins/views/layouts.py
index 67c8b3a..567ca53 100644
--- a/web/plugins/views/layouts.py
+++ b/web/plugins/views/layouts.py
@@ -591,6 +591,7 @@ def csv_export_matrix(rows, view, group_painters, painters):
output_csv_headers(view)
groups, unique_row_ids, matrix_cells = list(create_matrices(rows, group_painters,
painters, num_columns=None))[0]
+ value_counts, row_majorities = matrix_find_majorities(rows, painters, False)
table.begin(output_format="csv")
for painter_nr, painter in enumerate(group_painters):