Expose params and type key for report output
This commit is contained in:
parent
118f22c164
commit
6ef217c546
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue