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.trainwreck', 'model', 'rattail.trainwreck.db.model.defaults')
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
config.setdefault('rattail', 'products.handler', 'rattail_corepos.products:CoreProductsHandler')

View file

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