Add jump buttons to view product, vendor in CORE Office
hopefully can use the same pattern for anything else that comes up
This commit is contained in:
parent
32f381bdd2
commit
dbde3cbfbe
18
tailbone_corepos/templates/corepos-util.mako
Normal file
18
tailbone_corepos/templates/corepos-util.mako
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
## -*- coding: utf-8; -*-
|
||||||
|
|
||||||
|
<%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>
|
11
tailbone_corepos/templates/products/view.mako
Normal file
11
tailbone_corepos/templates/products/view.mako
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
## -*- coding: utf-8; -*-
|
||||||
|
<%inherit file="tailbone:templates/products/view.mako" />
|
||||||
|
<%namespace file="/corepos-util.mako" import="render_xref_helper" />
|
||||||
|
|
||||||
|
<%def name="object_helpers()">
|
||||||
|
${parent.object_helpers()}
|
||||||
|
${render_xref_helper()}
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
|
||||||
|
${parent.body()}
|
11
tailbone_corepos/templates/vendors/view.mako
vendored
Normal file
11
tailbone_corepos/templates/vendors/view.mako
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
## -*- coding: utf-8; -*-
|
||||||
|
<%inherit file="/master/view.mako" />
|
||||||
|
<%namespace file="/corepos-util.mako" import="render_xref_helper" />
|
||||||
|
|
||||||
|
<%def name="object_helpers()">
|
||||||
|
${parent.object_helpers()}
|
||||||
|
${render_xref_helper()}
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
|
||||||
|
${parent.body()}
|
56
tailbone_corepos/views/products.py
Normal file
56
tailbone_corepos/views/products.py
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
# -*- coding: utf-8; -*-
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Rattail -- Retail Software Framework
|
||||||
|
# Copyright © 2010-2020 Lance Edgar
|
||||||
|
#
|
||||||
|
# This file is part of Rattail.
|
||||||
|
#
|
||||||
|
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||||
|
# terms of the GNU General Public License as published by the Free Software
|
||||||
|
# Foundation, either version 3 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
# details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along with
|
||||||
|
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
"""
|
||||||
|
Product Views
|
||||||
|
"""
|
||||||
|
|
||||||
|
from rattail_corepos.config import core_office_url
|
||||||
|
|
||||||
|
from tailbone.views import products as base
|
||||||
|
|
||||||
|
|
||||||
|
class ProductView(base.ProductsView):
|
||||||
|
"""
|
||||||
|
Master view for the Product class.
|
||||||
|
"""
|
||||||
|
|
||||||
|
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(ProductView, 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
|
|
@ -1,8 +1,30 @@
|
||||||
# -*- coding: utf-8; -*-
|
# -*- coding: utf-8; -*-
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# Rattail -- Retail Software Framework
|
||||||
|
# Copyright © 2010-2019 Lance Edgar
|
||||||
|
#
|
||||||
|
# This file is part of Rattail.
|
||||||
|
#
|
||||||
|
# Rattail is free software: you can redistribute it and/or modify it under the
|
||||||
|
# terms of the GNU General Public License as published by the Free Software
|
||||||
|
# Foundation, either version 3 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
# details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along with
|
||||||
|
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
"""
|
"""
|
||||||
Vendor views
|
Vendor views
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from rattail_corepos.config import core_office_url
|
||||||
from rattail_corepos.corepos.util import get_max_existing_vendor_id
|
from rattail_corepos.corepos.util import get_max_existing_vendor_id
|
||||||
|
|
||||||
from tailbone.views import vendors as base
|
from tailbone.views import vendors as base
|
||||||
|
@ -56,3 +78,30 @@ class VendorView(base.VendorsView):
|
||||||
vendor.special_discount = 0
|
vendor.special_discount = 0
|
||||||
|
|
||||||
return vendor
|
return vendor
|
||||||
|
|
||||||
|
def template_kwargs_view(self, **kwargs):
|
||||||
|
"""
|
||||||
|
Supplements the default logic as follows:
|
||||||
|
|
||||||
|
Adds the URL for viewing the vendor within CORE Office, or else the
|
||||||
|
reason for lack of such a URL.
|
||||||
|
"""
|
||||||
|
# invoke default/parent logic, if it exists
|
||||||
|
parent = super(VendorView, self)
|
||||||
|
if hasattr(parent, 'template_kwargs_view'):
|
||||||
|
kwargs = parent.template_kwargs_view(**kwargs)
|
||||||
|
|
||||||
|
vendor = 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"
|
||||||
|
elif not vendor.corepos_id:
|
||||||
|
kwargs['core_office_why_no_url'] = "Vendor has no CORE-POS ID"
|
||||||
|
else:
|
||||||
|
kwargs['core_office_url'] = '{}/item/vendors/VendorIndexPage.php?vid={}'.format(
|
||||||
|
office_url, vendor.corepos_id)
|
||||||
|
|
||||||
|
return kwargs
|
||||||
|
|
Loading…
Reference in a new issue