Add jumps links for all "supported" CORE-POS object views
This commit is contained in:
parent
dbde3cbfbe
commit
36d9eb3f4b
14 changed files with 146 additions and 1 deletions
|
@ -85,6 +85,10 @@ class CustomerView(CoreOfficeMasterView):
|
|||
f.remove_field('member_type')
|
||||
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):
|
||||
CustomerView.defaults(config)
|
||||
|
|
|
@ -79,6 +79,10 @@ class DepartmentView(CoreOfficeMasterView):
|
|||
g.set_link('number')
|
||||
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):
|
||||
DepartmentView.defaults(config)
|
||||
|
|
|
@ -69,6 +69,10 @@ class EmployeeView(CoreOfficeMasterView):
|
|||
if not employee.active:
|
||||
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):
|
||||
EmployeeView.defaults(config)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2019 Lance Edgar
|
||||
# Copyright © 2010-2020 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -25,6 +25,7 @@ CORE POS master view
|
|||
"""
|
||||
|
||||
from rattail.util import OrderedDict
|
||||
from rattail_corepos.config import core_office_url
|
||||
|
||||
from webhelpers2.html import tags
|
||||
|
||||
|
@ -75,3 +76,30 @@ class CoreOfficeMasterView(MasterView):
|
|||
text = "({}) {}".format(vendor.abbreviation, vendor.name)
|
||||
url = self.request.route_url('corepos.vendors.view', id=vendor.id)
|
||||
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)
|
||||
|
||||
def core_office_object_url(self, office_url, product):
|
||||
return '{}/item/ItemEditorPage.php?searchupc={}'.format(
|
||||
office_url, product.upc)
|
||||
|
||||
|
||||
class ProductFlagView(CoreOfficeMasterView):
|
||||
"""
|
||||
|
|
|
@ -78,6 +78,10 @@ class VendorView(CoreOfficeMasterView):
|
|||
if self.creating:
|
||||
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):
|
||||
VendorView.defaults(config)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue