diff --git a/tailbone/views/reports.py b/tailbone/views/reports.py index ac349138..bd498de3 100644 --- a/tailbone/views/reports.py +++ b/tailbone/views/reports.py @@ -29,7 +29,6 @@ from __future__ import unicode_literals, absolute_import import re import rattail -from rattail import enum from rattail.db import model from rattail.files import resource_path from rattail.time import localtime @@ -37,7 +36,6 @@ from rattail.time import localtime from mako.template import Template from pyramid.response import Response -from tailbone import forms from tailbone.db import Session from tailbone.views import View from tailbone.views.exports import ExportMasterView @@ -212,27 +210,27 @@ class ReportOutputView(ExportMasterView): 'created_by', ] + form_fields = [ + 'id', + 'report_name', + 'filename', + 'created', + 'created_by', + ] + def configure_grid(self, g): super(ReportOutputView, self).configure_grid(g) g.set_link('filename') - def _preconfigure_fieldset(self, fs): - super(ReportOutputView, self)._preconfigure_fieldset(fs) + def configure_form(self, f): + super(ReportOutputView, self).configure_form(f) if self.viewing: - report = self.get_instance() - download = forms.renderers.FileFieldRenderer.new(self, - storage_path=report.filepath(self.rattail_config, filename=None), - file_path=report.filepath(self.rattail_config)) - fs.filename.set(renderer=download) + f.set_renderer('filename', self.render_download) - def configure_fieldset(self, fs): - fs.configure(include=[ - fs.id, - fs.report_name, - fs.filename, - fs.created, - fs.created_by, - ]) + def render_download(self, report, field): + path = report.filepath(self.rattail_config) + url = self.get_action_url('download', report) + return self.render_file_field(path, url=url) def download(self): report = self.get_instance()