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 Custom config
""" """
@ -19,7 +20,7 @@ class CorporalConfig(ConfigExtension):
# set some default config values # set some default config values
config.setdefault('rattail', 'model', 'corporal.db.model') config.setdefault('rattail', 'model', 'corporal.db.model')
config.setdefault('rattail', 'settings', 'corporal.settings') 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') config.setdefault('rattail.config', 'templates', 'corporal:data/config rattail:data/config')
# batches # batches

View file

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