Add jump button, to view product in CORE Office
This commit is contained in:
parent
72a4c347d8
commit
d7462f415d
27
rattail_demo/web/templates/products/view.mako
Normal file
27
rattail_demo/web/templates/products/view.mako
Normal file
|
@ -0,0 +1,27 @@
|
|||
## -*- 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()}
|
|
@ -1,9 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8; -*-
|
||||
"""
|
||||
Product views
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
from rattail_corepos.config import core_office_url
|
||||
|
||||
from tailbone.views import products as base
|
||||
|
||||
|
@ -55,6 +55,26 @@ class ProductsView(base.ProductsView):
|
|||
'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):
|
||||
|
||||
|
|
Loading…
Reference in a new issue