Use handler to build menus

This commit is contained in:
Lance Edgar 2023-01-14 16:13:58 -06:00
parent 6a8096391f
commit 316bdfe1aa
2 changed files with 327 additions and 323 deletions

View file

@ -20,7 +20,7 @@ class DemoConfigExtension(ConfigExtension):
config.setdefault('rattail', 'model', 'rattail_demo.db.model') config.setdefault('rattail', 'model', 'rattail_demo.db.model')
config.setdefault('rattail.trainwreck', 'model', 'rattail.trainwreck.db.model.defaults') config.setdefault('rattail.trainwreck', 'model', 'rattail.trainwreck.db.model.defaults')
config.setdefault('rattail.mail', 'emails', 'rattail_demo.emails') config.setdefault('rattail.mail', 'emails', 'rattail_demo.emails')
config.setdefault('tailbone', 'menus', 'rattail_demo.web.menus') config.setdefault('tailbone.menus', 'handler', 'rattail_demo.web.menus:DemoMenuHandler')
# default app handlers # default app handlers
config.setdefault('rattail', 'products.handler', 'rattail_corepos.products:CoreProductsHandler') config.setdefault('rattail', 'products.handler', 'rattail_corepos.products:CoreProductsHandler')

View file

@ -3,12 +3,16 @@
Web Menus Web Menus
""" """
from tailbone import menus as base
from tailbone_corepos.menus import make_corepos_menu from tailbone_corepos.menus import make_corepos_menu
def simple_menus(request): class DemoMenuHandler(base.MenuHandler):
url = request.route_url """
rattail_config = request.rattail_config Demo menu handler
"""
def make_menus(self, request, **kwargs):
people_menu = { people_menu = {
'title': "People", 'title': "People",
@ -333,7 +337,7 @@ def simple_menus(request):
batch_menu, batch_menu,
] ]
if rattail_config.trainwreck_engine: if self.config.trainwreck_engine:
menus.append(trainwreck_menu) menus.append(trainwreck_menu)
menus.extend([ menus.extend([