Only show DB picker for permissioned users

This commit is contained in:
Lance Edgar 2022-02-18 15:39:12 -06:00
parent b6bd095d8e
commit 57e22c9ff5
2 changed files with 18 additions and 13 deletions

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar
# Copyright © 2010-2022 Lance Edgar
#
# This file is part of Rattail.
#
@ -222,7 +222,9 @@ class CommonView(View):
config.add_tailbone_permission('common', 'common.change_db_engine',
"Change which Database Engine is active (for user)")
config.add_route('change_db_engine', '/change-db-engine', request_method='POST')
config.add_view(cls, attr='change_db_engine', route_name='change_db_engine')
config.add_view(cls, attr='change_db_engine',
route_name='change_db_engine',
permission='common.change_db_engine')
# change theme
config.add_tailbone_permission('common', 'common.change_app_theme',

View file

@ -2276,6 +2276,9 @@ class MasterView(View):
kwargs['expose_db_picker'] = False
if self.supports_multiple_engines:
# DB picker is only shown for permissioned users
if self.request.has_perm('common.change_db_engine'):
# view declares support for multiple engines, but we only want to
# show the picker if we have more than one engine configured
engines = self.get_db_engines()