Expose custorder xref markers for trainwreck
This commit is contained in:
parent
cdae4bf8da
commit
fc5b931007
|
@ -1,6 +1,15 @@
|
||||||
## -*- coding: utf-8; -*-
|
## -*- coding: utf-8; -*-
|
||||||
<%inherit file="/master/view.mako" />
|
<%inherit file="/master/view.mako" />
|
||||||
|
|
||||||
## nb. this exists just so everyone can inherit from it
|
<%def name="modify_this_page_vars()">
|
||||||
|
${parent.modify_this_page_vars()}
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
% if custorder_xref_markers_data is not Undefined:
|
||||||
|
${form.component_studly}Data.custorderXrefMarkersData = ${json.dumps(custorder_xref_markers_data)|n}
|
||||||
|
% endif
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</%def>
|
||||||
|
|
||||||
${parent.body()}
|
${parent.body()}
|
||||||
|
|
|
@ -91,6 +91,7 @@ class TransactionView(MasterView):
|
||||||
'shopper_id',
|
'shopper_id',
|
||||||
'shopper_name',
|
'shopper_name',
|
||||||
'shopper_level_number',
|
'shopper_level_number',
|
||||||
|
'custorder_xref_markers',
|
||||||
'subtotal',
|
'subtotal',
|
||||||
'discounted_subtotal',
|
'discounted_subtotal',
|
||||||
'tax',
|
'tax',
|
||||||
|
@ -136,6 +137,7 @@ class TransactionView(MasterView):
|
||||||
'subdepartment_number',
|
'subdepartment_number',
|
||||||
'subdepartment_name',
|
'subdepartment_name',
|
||||||
'description',
|
'description',
|
||||||
|
'custorder_item_xref',
|
||||||
'unit_quantity',
|
'unit_quantity',
|
||||||
'subtotal',
|
'subtotal',
|
||||||
'discounts',
|
'discounts',
|
||||||
|
@ -196,6 +198,9 @@ class TransactionView(MasterView):
|
||||||
f.set_type('total', 'currency')
|
f.set_type('total', 'currency')
|
||||||
f.set_type('patronage', 'currency')
|
f.set_type('patronage', 'currency')
|
||||||
|
|
||||||
|
# custorder_xref_markers
|
||||||
|
f.set_renderer('custorder_xref_markers', self.render_custorder_xref_markers)
|
||||||
|
|
||||||
# label overrides
|
# label overrides
|
||||||
f.set_label('system_id', "System ID")
|
f.set_label('system_id', "System ID")
|
||||||
f.set_label('terminal_id', "Terminal")
|
f.set_label('terminal_id', "Terminal")
|
||||||
|
@ -203,6 +208,45 @@ class TransactionView(MasterView):
|
||||||
f.set_label('customer_id', "Customer ID")
|
f.set_label('customer_id', "Customer ID")
|
||||||
f.set_label('shopper_id', "Shopper ID")
|
f.set_label('shopper_id', "Shopper ID")
|
||||||
|
|
||||||
|
def render_custorder_xref_markers(self, txn, field):
|
||||||
|
markers = getattr(txn, field)
|
||||||
|
if not markers:
|
||||||
|
return
|
||||||
|
|
||||||
|
route_prefix = self.get_route_prefix()
|
||||||
|
factory = self.get_grid_factory()
|
||||||
|
use_buefy = self.get_use_buefy()
|
||||||
|
|
||||||
|
g = factory(
|
||||||
|
key='{}.custorder_xref_markers'.format(route_prefix),
|
||||||
|
data=[] if use_buefy else txn.custorder_xref_markers,
|
||||||
|
columns=['custorder_xref', 'custorder_item_xref'],
|
||||||
|
request=self.request)
|
||||||
|
|
||||||
|
if use_buefy:
|
||||||
|
return HTML.literal(
|
||||||
|
g.render_buefy_table_element(data_prop='custorderXrefMarkersData'))
|
||||||
|
else:
|
||||||
|
return HTML.literal(g.render_grid())
|
||||||
|
|
||||||
|
def template_kwargs_view(self, **kwargs):
|
||||||
|
kwargs = super(TransactionView, self).template_kwargs_view(**kwargs)
|
||||||
|
|
||||||
|
use_buefy = self.get_use_buefy()
|
||||||
|
if use_buefy:
|
||||||
|
form = kwargs['form']
|
||||||
|
if 'custorder_xref_markers' in form:
|
||||||
|
txn = kwargs['instance']
|
||||||
|
markers = []
|
||||||
|
for marker in txn.custorder_xref_markers:
|
||||||
|
markers.append({
|
||||||
|
'custorder_xref': marker.custorder_xref,
|
||||||
|
'custorder_item_xref': marker.custorder_item_xref,
|
||||||
|
})
|
||||||
|
kwargs['custorder_xref_markers_data'] = markers
|
||||||
|
|
||||||
|
return kwargs
|
||||||
|
|
||||||
def get_row_data(self, transaction):
|
def get_row_data(self, transaction):
|
||||||
return self.Session.query(self.model_row_class)\
|
return self.Session.query(self.model_row_class)\
|
||||||
.filter(self.model_row_class.transaction == transaction)
|
.filter(self.model_row_class.transaction == transaction)
|
||||||
|
|
Loading…
Reference in a new issue