Move jump button logic to tailbone-corepos

since that now supports jump button for Vendor also, maybe others to come
This commit is contained in:
Lance Edgar 2020-03-14 19:50:35 -05:00
parent d7462f415d
commit 07a36982d7
3 changed files with 5 additions and 52 deletions

View file

@ -15,6 +15,7 @@ def main(global_config, **settings):
""" """
# prefer demo templates over tailbone # prefer demo templates over tailbone
settings.setdefault('mako.directories', ['rattail_demo.web:templates', settings.setdefault('mako.directories', ['rattail_demo.web:templates',
'tailbone_corepos:templates',
'tailbone:templates',]) 'tailbone:templates',])
# for graceful handling of postgres restart # for graceful handling of postgres restart

View file

@ -1,27 +0,0 @@
## -*- coding: utf-8; -*-
<%inherit file="tailbone:templates/products/view.mako" />
<%def name="object_helpers()">
${parent.object_helpers()}
${self.render_xref_helper()}
</%def>
<%def name="render_xref_helper()">
<div class="object-helper">
<h3>Cross-Reference</h3>
<div class="object-helper-content">
<b-button type="is-primary"
% if core_office_url:
tag="a" href="${core_office_url}" target="_blank"
% else:
disabled title="${core_office_why_no_url}"
% endif
>
View in CORE Office
</b-button>
</div>
</div>
</%def>
${parent.body()}

View file

@ -3,18 +3,17 @@
Product views Product views
""" """
from rattail_corepos.config import core_office_url
from tailbone.views import products as base from tailbone.views import products as base
from tailbone_corepos.views import products as corepos_base
class ProductsView(base.ProductsView): class ProductView(corepos_base.ProductView):
""" """
Product overrides for online demo Product overrides for online demo
""" """
def configure_form(self, f): def configure_form(self, f):
super(ProductsView, self).configure_form(f) super(ProductView, self).configure_form(f)
if self.editing: if self.editing:
f.fields = [ f.fields = [
@ -55,26 +54,6 @@ class ProductsView(base.ProductsView):
'deleted', 'deleted',
] ]
def template_kwargs_view(self, **kwargs):
"""
Supplements the default logic as follows:
Adds the URL for viewing the product within CORE Office, or else the
reason for lack of such a URL.
"""
kwargs = super(ProductsView, self).template_kwargs_view(**kwargs)
product = kwargs['instance']
# CORE Office URL
kwargs['core_office_url'] = None
office_url = core_office_url(self.rattail_config)
if not office_url:
kwargs['core_office_why_no_url'] = "CORE Office URL is not configured!"
else:
kwargs['core_office_url'] = '{}/item/ItemEditorPage.php?searchupc={}'.format(office_url, product.item_id)
return kwargs
def includeme(config): def includeme(config):
@ -86,4 +65,4 @@ def includeme(config):
config.add_view(base.print_labels, route_name='products.print_labels', config.add_view(base.print_labels, route_name='products.print_labels',
renderer='json', permission='products.print_labels') renderer='json', permission='products.print_labels')
ProductsView.defaults(config) ProductView.defaults(config)