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,123 +3,128 @@
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
"""
corepos_menu = make_corepos_menu(request)
def make_menus(self, request, **kwargs):
batch_menu = {
'title': "Batches",
'type': 'menu',
'items': [
{
'title': "CORE Member",
'url': url('batch.coremember'),
'perm': 'batch.coremember.list',
},
{
'title': "Vendor Catalogs",
'url': url('vendorcatalogs'),
'perm': 'vendorcatalogs.list',
},
],
}
corepos_menu = make_corepos_menu(request)
reports_menu = {
'title': "Reports",
'type': 'menu',
'items': [
{
'title': "New Report",
'route': 'report_output.create',
'perm': 'report_output.create',
},
{
'title': "Generated Reports",
'route': 'report_output',
'perm': 'report_output.list',
},
{
'title': "Problem Reports",
'route': 'problem_reports',
'perm': 'problem_reports.list',
},
{'type': 'sep'},
{
'title': "Poser Reports",
'route': 'poser_reports',
'perm': 'poser_reports.list',
},
],
}
batch_menu = {
'title': "Batches",
'type': 'menu',
'items': [
{
'title': "CORE Member",
'route': 'batch.coremember',
'perm': 'batch.coremember.list',
},
{
'title': "Vendor Catalogs",
'route': 'vendorcatalogs',
'perm': 'vendorcatalogs.list',
},
],
}
admin_menu = {
'title': "Admin",
'type': 'menu',
'items': [
{
'title': "Users",
'url': url('users'),
'perm': 'users.list',
},
{
'title': "User Events",
'url': url('userevents'),
'perm': 'userevents.list',
},
{
'title': "Roles",
'url': url('roles'),
'perm': 'roles.list',
},
{'type': 'sep'},
{
'title': "App Settings",
'url': url('appsettings'),
'perm': 'settings.list',
},
{
'title': "Email Settings",
'url': url('emailprofiles'),
'perm': 'emailprofiles.list',
},
{
'title': "Email Attempts",
'url': url('email_attempts'),
'perm': 'email_attempts.list',
},
{
'title': "Raw Settings",
'url': url('settings'),
'perm': 'settings.list',
},
{'type': 'sep'},
{
'title': "Tables",
'url': url('tables'),
'perm': 'tables.list',
},
{
'title': "Importing / Exporting",
'url': url('importing'),
'perm': 'importing.runjobs',
},
{
'title': "Corporal Upgrades",
'url': url('upgrades'),
'perm': 'upgrades.list',
},
],
}
reports_menu = {
'title': "Reports",
'type': 'menu',
'items': [
{
'title': "New Report",
'route': 'report_output.create',
'perm': 'report_output.create',
},
{
'title': "Generated Reports",
'route': 'report_output',
'perm': 'report_output.list',
},
{
'title': "Problem Reports",
'route': 'problem_reports',
'perm': 'problem_reports.list',
},
{'type': 'sep'},
{
'title': "Poser Reports",
'route': 'poser_reports',
'perm': 'poser_reports.list',
},
],
}
menus = [
corepos_menu,
batch_menu,
reports_menu,
admin_menu,
]
admin_menu = {
'title': "Admin",
'type': 'menu',
'items': [
{
'title': "Users",
'route': 'users',
'perm': 'users.list',
},
{
'title': "User Events",
'route': 'userevents',
'perm': 'userevents.list',
},
{
'title': "Roles",
'route': 'roles',
'perm': 'roles.list',
},
{'type': 'sep'},
{
'title': "App Settings",
'route': 'appsettings',
'perm': 'settings.list',
},
{
'title': "Email Settings",
'route': 'emailprofiles',
'perm': 'emailprofiles.list',
},
{
'title': "Email Attempts",
'route': 'email_attempts',
'perm': 'email_attempts.list',
},
{
'title': "Raw Settings",
'route': 'settings',
'perm': 'settings.list',
},
{'type': 'sep'},
{
'title': "Tables",
'route': 'tables',
'perm': 'tables.list',
},
{
'title': "Importing / Exporting",
'route': 'importing',
'perm': 'importing.runjobs',
},
{
'title': "Corporal Upgrades",
'route': 'upgrades',
'perm': 'upgrades.list',
},
],
}
return menus
menus = [
corepos_menu,
batch_menu,
reports_menu,
admin_menu,
]
return menus