From 6ef217c54639f6dfb537d29b92c143e7d14c8bae Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 7 May 2019 17:15:45 -0500 Subject: [PATCH] Expose params and type key for report output --- tailbone/views/reports.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tailbone/views/reports.py b/tailbone/views/reports.py index 0ae407d7..2f330075 100644 --- a/tailbone/views/reports.py +++ b/tailbone/views/reports.py @@ -42,8 +42,9 @@ from rattail.threads import Thread import colander from mako.template import Template from pyramid.response import Response +from webhelpers2.html import HTML -from tailbone import forms +from tailbone import forms, grids from tailbone.db import Session from tailbone.views import View from tailbone.views.exports import ExportMasterView @@ -224,6 +225,8 @@ class ReportOutputView(ExportMasterView): form_fields = [ 'id', 'report_name', + 'report_type', + 'params', 'filename', 'created', 'created_by', @@ -235,9 +238,31 @@ class ReportOutputView(ExportMasterView): def configure_form(self, f): super(ReportOutputView, self).configure_form(f) + + # params + f.set_renderer('params', self.render_params) + + # filename if self.viewing: f.set_renderer('filename', self.render_download) + def render_params(self, report, field): + params = report.params + if not params: + return "" + + # TODO: should sort these, perhaps according to Report definition? + params = [{'key': key, 'value': value} + for key, value in params.items()] + + route_prefix = self.get_route_prefix() + g = grids.Grid( + key='{}.params'.format(route_prefix), + data=params, + columns=['key', 'value'], + ) + return HTML.literal(g.render_grid()) + def render_download(self, report, field): path = report.filepath(self.rattail_config) url = self.get_action_url('download', report)