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

@ -2276,18 +2276,21 @@ class MasterView(View):
kwargs['expose_db_picker'] = False
if self.supports_multiple_engines:
# 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()
if len(engines) > 1:
# DB picker is only shown for permissioned users
if self.request.has_perm('common.change_db_engine'):
# user session determines "current" db engine *of this type*
# (note that many master views may declare the same type, and
# would therefore share the "current" engine)
selected = self.get_current_engine_dbkey()
kwargs['expose_db_picker'] = True
kwargs['db_picker_options'] = [tags.Option(k) for k in engines]
kwargs['db_picker_selected'] = selected
# 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()
if len(engines) > 1:
# user session determines "current" db engine *of this type*
# (note that many master views may declare the same type, and
# would therefore share the "current" engine)
selected = self.get_current_engine_dbkey()
kwargs['expose_db_picker'] = True
kwargs['db_picker_options'] = [tags.Option(k) for k in engines]
kwargs['db_picker_selected'] = selected
# add info for downloadable input file templates, if any
if self.has_input_file_templates: