Add jumps links for all "supported" CORE-POS object views

This commit is contained in:
Lance Edgar 2020-03-14 20:56:51 -05:00
parent dbde3cbfbe
commit 36d9eb3f4b
14 changed files with 146 additions and 1 deletions

View file

@ -0,0 +1,3 @@
## -*- coding: utf-8; -*-
<%inherit file="/core-pos/master/view.mako" />
${parent.body()}

View file

@ -0,0 +1,3 @@
## -*- coding: utf-8; -*-
<%inherit file="/core-pos/master/view.mako" />
${parent.body()}

View file

@ -0,0 +1,3 @@
## -*- coding: utf-8; -*-
<%inherit file="/core-pos/master/view.mako" />
${parent.body()}

View 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()}

View file

@ -0,0 +1,3 @@
## -*- coding: utf-8; -*-
<%inherit file="/core-pos/master/view.mako" />
${parent.body()}

View file

@ -0,0 +1,3 @@
## -*- coding: utf-8; -*-
<%inherit file="/core-pos/master/view.mako" />
${parent.body()}

View 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()}

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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.
"""

View file

@ -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):
""" """

View file

@ -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)

View 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