fix: add "other" menu entry, plus docs/tests
This commit is contained in:
parent
ce54ca6bd6
commit
c2f76f6c97
20 changed files with 546 additions and 15 deletions
|
@ -34,8 +34,9 @@ from sideshow.batch import neworder as base
|
|||
|
||||
class NewOrderBatchHandler(base.NewOrderBatchHandler):
|
||||
"""
|
||||
Custom batch handler which can use CORE-POS as external data
|
||||
source for customers and products.
|
||||
Custom :term:`handler` for :term:`new order batches <new order
|
||||
batch>` which can use CORE-POS as external data source for
|
||||
customers and products.
|
||||
|
||||
See parent class
|
||||
:class:`~sideshow:sideshow.batch.neworder.NewOrderBatchHandler`
|
||||
|
@ -96,7 +97,7 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
|
|||
.options(orm.joinedload(op_model.CustomerClassic.member_info))\
|
||||
.one()
|
||||
except orm.exc.NoResultFound:
|
||||
raise ValueError(f"CORE-POS Customer not found: {customer_id}")
|
||||
raise ValueError(f"CORE-POS Customer not found: {batch.customer_id}")
|
||||
|
||||
batch.customer_name = str(customer)
|
||||
batch.phone_number = customer.member_info.phone
|
||||
|
@ -132,19 +133,16 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
|
|||
# get results
|
||||
def result(product):
|
||||
return {'value': product.upc,
|
||||
'label': product.formatted_name}
|
||||
'label': self.app.make_full_name(product.brand,
|
||||
product.description,
|
||||
product.size)}
|
||||
results = [result(c) for c in products]
|
||||
|
||||
op_session.close()
|
||||
return results
|
||||
|
||||
def get_product_info_external(self, session, product_id, user=None):
|
||||
"""
|
||||
Returns basic info for an :term:`external product` as pertains
|
||||
to ordering.
|
||||
|
||||
There is no default logic here; subclass must implement.
|
||||
"""
|
||||
""" """
|
||||
corepos = self.app.get_corepos_handler()
|
||||
op_model = corepos.get_model_office_op()
|
||||
op_session = corepos.make_session_office_op()
|
||||
|
@ -162,7 +160,6 @@ class NewOrderBatchHandler(base.NewOrderBatchHandler):
|
|||
'brand_name': product.brand,
|
||||
'description': product.description,
|
||||
'size': product.size,
|
||||
# 'full_description': product.formatted_name,
|
||||
'full_description': self.app.make_full_name(product.brand,
|
||||
product.description,
|
||||
product.size),
|
||||
|
|
|
@ -35,7 +35,6 @@ def main(global_config, **settings):
|
|||
"""
|
||||
# prefer Sideshow templates over wuttaweb
|
||||
settings.setdefault('mako.directories', [
|
||||
# 'sideshow_corepos.web:templates',
|
||||
'sideshow.web:templates',
|
||||
'wuttaweb:templates',
|
||||
])
|
||||
|
@ -63,6 +62,6 @@ def make_wsgi_app():
|
|||
|
||||
def make_asgi_app():
|
||||
"""
|
||||
Make and return the ASGI app.
|
||||
Make and return the ASGI app (generic entry point).
|
||||
"""
|
||||
return base.make_asgi_app(main)
|
||||
|
|
|
@ -34,7 +34,7 @@ class SideshowMenuHandler(base.SideshowMenuHandler):
|
|||
|
||||
def make_customers_menu(self, request, **kwargs):
|
||||
"""
|
||||
This adds the entry for CORE-POS Members..
|
||||
This adds the entry for CORE-POS Members.
|
||||
"""
|
||||
menu = super().make_customers_menu(request, **kwargs)
|
||||
|
||||
|
@ -51,7 +51,7 @@ class SideshowMenuHandler(base.SideshowMenuHandler):
|
|||
|
||||
def make_products_menu(self, request, **kwargs):
|
||||
"""
|
||||
This adds the entry for CORE-POS Products..
|
||||
This adds the entry for CORE-POS Products.
|
||||
"""
|
||||
menu = super().make_products_menu(request, **kwargs)
|
||||
|
||||
|
@ -65,3 +65,22 @@ class SideshowMenuHandler(base.SideshowMenuHandler):
|
|||
])
|
||||
|
||||
return menu
|
||||
|
||||
def make_other_menu(self, request, **kwargs):
|
||||
"""
|
||||
This adds the entry for CORE Office.
|
||||
"""
|
||||
menu = super().make_other_menu(request, **kwargs)
|
||||
|
||||
corepos = self.app.get_corepos_handler()
|
||||
url = corepos.get_office_url()
|
||||
if url:
|
||||
menu['items'].extend([
|
||||
{
|
||||
'title': "CORE Office",
|
||||
'url': url,
|
||||
'target': '_blank',
|
||||
},
|
||||
])
|
||||
|
||||
return menu
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
################################################################################
|
||||
"""
|
||||
Sideshow-COREPOS - custom views
|
||||
|
||||
This adds config for readonly views for CORE-POS members and products.
|
||||
"""
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue