diff --git a/tailbone/views/trainwreck/base.py b/tailbone/views/trainwreck/base.py index 82a0b2b1..8ac243a0 100644 --- a/tailbone/views/trainwreck/base.py +++ b/tailbone/views/trainwreck/base.py @@ -24,8 +24,6 @@ Trainwreck views """ -from rattail.time import localtime - from webhelpers2.html import HTML, tags from tailbone.db import Session, TrainwreckSession, ExtraTrainwreckSessions @@ -44,6 +42,7 @@ class TransactionView(MasterView): creatable = False editable = False deletable = False + results_downloadable = True supports_multiple_engines = True engine_type_key = 'trainwreck' @@ -152,14 +151,29 @@ class TransactionView(MasterView): trainwreck_handler = app.get_trainwreck_handler() 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): super(TransactionView, self).configure_grid(g) + app = self.get_rattail_app() + g.filters['receipt_number'].default_active = True g.filters['receipt_number'].default_verb = 'equal' g.filters['end_time'].default_active = True 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_enum('system', self.enum.TRAINWRECK_SYSTEM)