Add jumps links for all "supported" CORE-POS object views
This commit is contained in:
parent
dbde3cbfbe
commit
36d9eb3f4b
3
tailbone_corepos/templates/core-pos/customers/view.mako
Normal file
3
tailbone_corepos/templates/core-pos/customers/view.mako
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
## -*- coding: utf-8; -*-
|
||||||
|
<%inherit file="/core-pos/master/view.mako" />
|
||||||
|
${parent.body()}
|
|
@ -0,0 +1,3 @@
|
||||||
|
## -*- coding: utf-8; -*-
|
||||||
|
<%inherit file="/core-pos/master/view.mako" />
|
||||||
|
${parent.body()}
|
3
tailbone_corepos/templates/core-pos/employees/view.mako
Normal file
3
tailbone_corepos/templates/core-pos/employees/view.mako
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
## -*- coding: utf-8; -*-
|
||||||
|
<%inherit file="/core-pos/master/view.mako" />
|
||||||
|
${parent.body()}
|
11
tailbone_corepos/templates/core-pos/master/view.mako
Normal file
11
tailbone_corepos/templates/core-pos/master/view.mako
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()}
|
3
tailbone_corepos/templates/core-pos/products/view.mako
Normal file
3
tailbone_corepos/templates/core-pos/products/view.mako
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
## -*- coding: utf-8; -*-
|
||||||
|
<%inherit file="/core-pos/master/view.mako" />
|
||||||
|
${parent.body()}
|
3
tailbone_corepos/templates/core-pos/vendors/view.mako
vendored
Normal file
3
tailbone_corepos/templates/core-pos/vendors/view.mako
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
## -*- coding: utf-8; -*-
|
||||||
|
<%inherit file="/core-pos/master/view.mako" />
|
||||||
|
${parent.body()}
|
11
tailbone_corepos/templates/departments/view.mako
Normal file
11
tailbone_corepos/templates/departments/view.mako
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
## -*- coding: utf-8; -*-
|
||||||
|
<%inherit file="tailbone:templates/departments/view.mako" />
|
||||||
|
<%namespace file="/corepos-util.mako" import="render_xref_helper" />
|
||||||
|
|
||||||
|
<%def name="object_helpers()">
|
||||||
|
${parent.object_helpers()}
|
||||||
|
${render_xref_helper()}
|
||||||
|
</%def>
|
||||||
|
|
||||||
|
|
||||||
|
${parent.body()}
|
|
@ -85,6 +85,10 @@ class CustomerView(CoreOfficeMasterView):
|
||||||
f.remove_field('member_type')
|
f.remove_field('member_type')
|
||||||
f.remove_field('last_change')
|
f.remove_field('last_change')
|
||||||
|
|
||||||
|
def core_office_object_url(self, office_url, customer):
|
||||||
|
return '{}/mem/MemberEditor.php?memNum={}'.format(
|
||||||
|
office_url, customer.card_number)
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
CustomerView.defaults(config)
|
CustomerView.defaults(config)
|
||||||
|
|
|
@ -79,6 +79,10 @@ class DepartmentView(CoreOfficeMasterView):
|
||||||
g.set_link('number')
|
g.set_link('number')
|
||||||
g.set_link('name')
|
g.set_link('name')
|
||||||
|
|
||||||
|
def core_office_object_url(self, office_url, department):
|
||||||
|
return '{}/item/departments/DepartmentEditor.php?did={}'.format(
|
||||||
|
office_url, department.number)
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
DepartmentView.defaults(config)
|
DepartmentView.defaults(config)
|
||||||
|
|
|
@ -69,6 +69,10 @@ class EmployeeView(CoreOfficeMasterView):
|
||||||
if not employee.active:
|
if not employee.active:
|
||||||
return 'warning'
|
return 'warning'
|
||||||
|
|
||||||
|
def core_office_object_url(self, office_url, employee):
|
||||||
|
return '{}/admin/Cashiers/CashierEditor.php?emp_no={}'.format(
|
||||||
|
office_url, employee.number)
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
EmployeeView.defaults(config)
|
EmployeeView.defaults(config)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2019 Lance Edgar
|
# Copyright © 2010-2020 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -25,6 +25,7 @@ CORE POS master view
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from rattail.util import OrderedDict
|
from rattail.util import OrderedDict
|
||||||
|
from rattail_corepos.config import core_office_url
|
||||||
|
|
||||||
from webhelpers2.html import tags
|
from webhelpers2.html import tags
|
||||||
|
|
||||||
|
@ -75,3 +76,30 @@ class CoreOfficeMasterView(MasterView):
|
||||||
text = "({}) {}".format(vendor.abbreviation, vendor.name)
|
text = "({}) {}".format(vendor.abbreviation, vendor.name)
|
||||||
url = self.request.route_url('corepos.vendors.view', id=vendor.id)
|
url = self.request.route_url('corepos.vendors.view', id=vendor.id)
|
||||||
return tags.link_to(text, url)
|
return tags.link_to(text, url)
|
||||||
|
|
||||||
|
def template_kwargs_view(self, **kwargs):
|
||||||
|
"""
|
||||||
|
Adds the URL for viewing the record/object within CORE Office, or else
|
||||||
|
the reason for lack of such a URL.
|
||||||
|
"""
|
||||||
|
obj = 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:
|
||||||
|
url = self.core_office_object_url(office_url, obj)
|
||||||
|
if url:
|
||||||
|
kwargs['core_office_url'] = url
|
||||||
|
else:
|
||||||
|
kwargs['core_office_why_no_url'] = "URL not defined for this object"
|
||||||
|
|
||||||
|
return kwargs
|
||||||
|
|
||||||
|
def core_office_object_url(self, office_url, obj):
|
||||||
|
"""
|
||||||
|
Subclass must define this logic; should return the "final" CORE Office
|
||||||
|
URL for the given object.
|
||||||
|
"""
|
||||||
|
|
|
@ -131,6 +131,10 @@ class ProductView(CoreOfficeMasterView):
|
||||||
|
|
||||||
return HTML.tag('ul', c=items)
|
return HTML.tag('ul', c=items)
|
||||||
|
|
||||||
|
def core_office_object_url(self, office_url, product):
|
||||||
|
return '{}/item/ItemEditorPage.php?searchupc={}'.format(
|
||||||
|
office_url, product.upc)
|
||||||
|
|
||||||
|
|
||||||
class ProductFlagView(CoreOfficeMasterView):
|
class ProductFlagView(CoreOfficeMasterView):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -78,6 +78,10 @@ class VendorView(CoreOfficeMasterView):
|
||||||
if self.creating:
|
if self.creating:
|
||||||
f.remove_field('contact')
|
f.remove_field('contact')
|
||||||
|
|
||||||
|
def core_office_object_url(self, office_url, vendor):
|
||||||
|
return '{}/item/vendors/VendorIndexPage.php?vid={}'.format(
|
||||||
|
office_url, vendor.id)
|
||||||
|
|
||||||
|
|
||||||
def includeme(config):
|
def includeme(config):
|
||||||
VendorView.defaults(config)
|
VendorView.defaults(config)
|
||||||
|
|
60
tailbone_corepos/views/departments.py
Normal file
60
tailbone_corepos/views/departments.py
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
# -*- 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/>.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
"""
|
||||||
|
Department Views
|
||||||
|
"""
|
||||||
|
|
||||||
|
from rattail_corepos.config import core_office_url
|
||||||
|
|
||||||
|
from tailbone.views import departments as base
|
||||||
|
|
||||||
|
|
||||||
|
class DepartmentView(base.DepartmentsView):
|
||||||
|
"""
|
||||||
|
Master view for the Department class.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def template_kwargs_view(self, **kwargs):
|
||||||
|
"""
|
||||||
|
Supplements the default logic as follows:
|
||||||
|
|
||||||
|
Adds the URL for viewing the department within CORE Office, or else the
|
||||||
|
reason for lack of such a URL.
|
||||||
|
"""
|
||||||
|
# invoke default/parent logic, if it exists
|
||||||
|
parent = super(DepartmentView, self)
|
||||||
|
if hasattr(parent, 'template_kwargs_view'):
|
||||||
|
kwargs = parent.template_kwargs_view(**kwargs)
|
||||||
|
|
||||||
|
department = 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/departments/DepartmentEditor.php?did={}'.format(
|
||||||
|
office_url, department.number)
|
||||||
|
|
||||||
|
return kwargs
|
Loading…
Reference in a new issue