Refactor reports view to use master3
This commit is contained in:
parent
09ba419ee3
commit
ef720e3a59
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue