Use handler to build menus

This commit is contained in:
Lance Edgar 2023-01-14 16:09:10 -06:00
parent 8c474e14d4
commit 8463af46e0
2 changed files with 118 additions and 112 deletions

View file

@ -1,3 +1,4 @@
# -*- coding: utf-8; -*-
"""
Custom config
"""
@ -19,7 +20,7 @@ class CorporalConfig(ConfigExtension):
# set some default config values
config.setdefault('rattail', 'model', 'corporal.db.model')
config.setdefault('rattail', 'settings', 'corporal.settings')
config.setdefault('tailbone', 'menus', 'corporal.web.menus')
config.setdefault('tailbone.menus', 'handler', 'corporal.web.menus:CorporalMenuHandler')
config.setdefault('rattail.config', 'templates', 'corporal:data/config rattail:data/config')
# batches

View file

@ -3,11 +3,16 @@
Corporal Web Menus
"""
from tailbone import menus as base
from tailbone_corepos.menus import make_corepos_menu
def simple_menus(request):
url = request.route_url
class CorporalMenuHandler(base.MenuHandler):
"""
Corporal menu handler
"""
def make_menus(self, request, **kwargs):
corepos_menu = make_corepos_menu(request)
@ -17,12 +22,12 @@ def simple_menus(request):
'items': [
{
'title': "CORE Member",
'url': url('batch.coremember'),
'route': 'batch.coremember',
'perm': 'batch.coremember.list',
},
{
'title': "Vendor Catalogs",
'url': url('vendorcatalogs'),
'route': 'vendorcatalogs',
'perm': 'vendorcatalogs.list',
},
],
@ -62,54 +67,54 @@ def simple_menus(request):
'items': [
{
'title': "Users",
'url': url('users'),
'route': 'users',
'perm': 'users.list',
},
{
'title': "User Events",
'url': url('userevents'),
'route': 'userevents',
'perm': 'userevents.list',
},
{
'title': "Roles",
'url': url('roles'),
'route': 'roles',
'perm': 'roles.list',
},
{'type': 'sep'},
{
'title': "App Settings",
'url': url('appsettings'),
'route': 'appsettings',
'perm': 'settings.list',
},
{
'title': "Email Settings",
'url': url('emailprofiles'),
'route': 'emailprofiles',
'perm': 'emailprofiles.list',
},
{
'title': "Email Attempts",
'url': url('email_attempts'),
'route': 'email_attempts',
'perm': 'email_attempts.list',
},
{
'title': "Raw Settings",
'url': url('settings'),
'route': 'settings',
'perm': 'settings.list',
},
{'type': 'sep'},
{
'title': "Tables",
'url': url('tables'),
'route': 'tables',
'perm': 'tables.list',
},
{
'title': "Importing / Exporting",
'url': url('importing'),
'route': 'importing',
'perm': 'importing.runjobs',
},
{
'title': "Corporal Upgrades",
'url': url('upgrades'),
'route': 'upgrades',
'perm': 'upgrades.list',
},
],