Allow download results for Trainwreck

just basic transaction headers so far..
This commit is contained in:
Lance Edgar 2023-02-28 15:05:38 -06:00
parent ad311e9e7e
commit e8f235e4f7

View file

@ -24,8 +24,6 @@
Trainwreck views Trainwreck views
""" """
from rattail.time import localtime
from webhelpers2.html import HTML, tags from webhelpers2.html import HTML, tags
from tailbone.db import Session, TrainwreckSession, ExtraTrainwreckSessions from tailbone.db import Session, TrainwreckSession, ExtraTrainwreckSessions
@ -44,6 +42,7 @@ class TransactionView(MasterView):
creatable = False creatable = False
editable = False editable = False
deletable = False deletable = False
results_downloadable = True
supports_multiple_engines = True supports_multiple_engines = True
engine_type_key = 'trainwreck' engine_type_key = 'trainwreck'
@ -152,14 +151,29 @@ class TransactionView(MasterView):
trainwreck_handler = app.get_trainwreck_handler() trainwreck_handler = app.get_trainwreck_handler()
return trainwreck_handler.get_trainwreck_engines(include_hidden=False) return trainwreck_handler.get_trainwreck_engines(include_hidden=False)
def make_isolated_session(self):
from rattail.trainwreck.db import Session as TrainwreckSession
dbkey = self.get_current_engine_dbkey()
if dbkey != 'default':
app = self.get_rattail_app()
trainwreck_handler = app.get_trainwreck_handler()
trainwreck_engines = trainwreck_handler.get_trainwreck_engines()
if dbkey in trainwreck_engines:
return TrainwreckSesssion(bind=trainwreck_engines[dbkey])
return TrainwreckSession()
def configure_grid(self, g): def configure_grid(self, g):
super(TransactionView, self).configure_grid(g) super(TransactionView, self).configure_grid(g)
app = self.get_rattail_app()
g.filters['receipt_number'].default_active = True g.filters['receipt_number'].default_active = True
g.filters['receipt_number'].default_verb = 'equal' g.filters['receipt_number'].default_verb = 'equal'
g.filters['end_time'].default_active = True g.filters['end_time'].default_active = True
g.filters['end_time'].default_verb = 'equal' g.filters['end_time'].default_verb = 'equal'
g.filters['end_time'].default_value = str(localtime(self.rattail_config).date()) g.filters['end_time'].default_value = str(app.today())
g.set_sort_defaults('end_time', 'desc') g.set_sort_defaults('end_time', 'desc')
g.set_enum('system', self.enum.TRAINWRECK_SYSTEM) g.set_enum('system', self.enum.TRAINWRECK_SYSTEM)