Auto-register all config pages, for dropdown in App Settings
This commit is contained in:
parent
6f62f141d2
commit
ca57bd3572
|
@ -156,9 +156,23 @@ def make_pyramid_config(settings, configure_csrf=True):
|
||||||
config.add_directive('add_tailbone_permission_group', 'tailbone.auth.add_permission_group')
|
config.add_directive('add_tailbone_permission_group', 'tailbone.auth.add_permission_group')
|
||||||
config.add_directive('add_tailbone_permission', 'tailbone.auth.add_permission')
|
config.add_directive('add_tailbone_permission', 'tailbone.auth.add_permission')
|
||||||
|
|
||||||
|
# and some similar magic for config views
|
||||||
|
config.add_directive('add_tailbone_config_page', 'tailbone.app.add_config_page')
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
def add_config_page(config, route_name, label):
|
||||||
|
"""
|
||||||
|
Register a config page for the app.
|
||||||
|
"""
|
||||||
|
def action():
|
||||||
|
pages = config.get_settings().get('tailbone_config_pages', [])
|
||||||
|
pages.append({'label': label, 'route': route_name})
|
||||||
|
config.add_settings({'tailbone_config_pages': pages})
|
||||||
|
config.action(None, action)
|
||||||
|
|
||||||
|
|
||||||
def establish_theme(settings):
|
def establish_theme(settings):
|
||||||
rattail_config = settings['rattail_config']
|
rattail_config = settings['rattail_config']
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,8 @@
|
||||||
|
|
||||||
<section class="modal-card-body">
|
<section class="modal-card-body">
|
||||||
<p class="block">
|
<p class="block">
|
||||||
If you like we can remove all ${config_title}
|
If you like we can remove all settings for ${config_title}
|
||||||
settings from the DB.
|
from the DB.
|
||||||
</p>
|
</p>
|
||||||
<p class="block">
|
<p class="block">
|
||||||
Note that the tool normally removes all settings first,
|
Note that the tool normally removes all settings first,
|
||||||
|
|
|
@ -4281,6 +4281,8 @@ class MasterView(View):
|
||||||
config.add_view(cls, attr='configure',
|
config.add_view(cls, attr='configure',
|
||||||
route_name='{}.configure'.format(route_prefix),
|
route_name='{}.configure'.format(route_prefix),
|
||||||
permission='{}.configure'.format(permission_prefix))
|
permission='{}.configure'.format(permission_prefix))
|
||||||
|
config.add_tailbone_config_page('{}.configure'.format(route_prefix),
|
||||||
|
config_title)
|
||||||
|
|
||||||
# quickie (search)
|
# quickie (search)
|
||||||
if cls.supports_quickie_search:
|
if cls.supports_quickie_search:
|
||||||
|
|
|
@ -125,23 +125,9 @@ class AppSettingsView(View):
|
||||||
if not current_group:
|
if not current_group:
|
||||||
current_group = self.request.session.get('appsettings.current_group')
|
current_group = self.request.session.get('appsettings.current_group')
|
||||||
|
|
||||||
# TODO: this should come from somewhere else
|
possible_config_options = sorted(
|
||||||
possible_config_options = [
|
self.request.registry.settings['tailbone_config_pages'],
|
||||||
{'label': "DataSync",
|
key=lambda p: p['label'])
|
||||||
'route': 'datasync.configure'},
|
|
||||||
{'label': "Email",
|
|
||||||
'route': 'emailprofiles.configure'},
|
|
||||||
{'label': "Importing / Exporting",
|
|
||||||
'route': 'importing.configure'},
|
|
||||||
{'label': "Products",
|
|
||||||
'route': 'products.configure'},
|
|
||||||
{'label': "Receiving",
|
|
||||||
'route': 'receiving.configure'},
|
|
||||||
{'label': "Reporting",
|
|
||||||
'route': 'report_output.configure'},
|
|
||||||
{'label': "Vendors",
|
|
||||||
'route': 'vendors.configure'},
|
|
||||||
]
|
|
||||||
|
|
||||||
config_options = []
|
config_options = []
|
||||||
for option in possible_config_options:
|
for option in possible_config_options:
|
||||||
|
|
Loading…
Reference in a new issue