Show link to txn as field when viewing trainwreck item
This commit is contained in:
parent
c72d99794e
commit
ab3a66542d
|
@ -30,7 +30,7 @@ import six
|
|||
|
||||
from rattail.time import localtime
|
||||
|
||||
from webhelpers2.html import HTML
|
||||
from webhelpers2.html import HTML, tags
|
||||
|
||||
from tailbone.db import Session, TrainwreckSession, ExtraTrainwreckSessions
|
||||
from tailbone.views import MasterView
|
||||
|
@ -128,6 +128,7 @@ class TransactionView(MasterView):
|
|||
]
|
||||
|
||||
row_form_fields = [
|
||||
'transaction',
|
||||
'sequence',
|
||||
'item_type',
|
||||
'item_scancode',
|
||||
|
@ -271,9 +272,15 @@ class TransactionView(MasterView):
|
|||
if row.void:
|
||||
return 'warning'
|
||||
|
||||
def get_row_instance_title(self, instance):
|
||||
return "Trainwreck Line Item"
|
||||
|
||||
def configure_row_form(self, f):
|
||||
super(TransactionView, self).configure_row_form(f)
|
||||
|
||||
# transaction
|
||||
f.set_renderer('transaction', self.render_transaction)
|
||||
|
||||
# quantity fields
|
||||
f.set_type('unit_quantity', 'quantity')
|
||||
|
||||
|
@ -287,6 +294,12 @@ class TransactionView(MasterView):
|
|||
# discounts
|
||||
f.set_renderer('discounts', self.render_discounts)
|
||||
|
||||
def render_transaction(self, item, field):
|
||||
txn = getattr(item, field)
|
||||
text = six.text_type(txn)
|
||||
url = self.get_action_url('view', txn)
|
||||
return tags.link_to(text, url)
|
||||
|
||||
def render_discounts(self, item, field):
|
||||
if not item.discounts:
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue