Skip to content

Commit

Permalink
Prevent duplicated view_menu perms (#1751)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkyryliuk authored Dec 2, 2016
1 parent 9d4c3d8 commit 09d597f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions superset/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,8 @@ def sync_role_definitions():
get_or_create_main_db()

# Global perms
sm.add_permission_view_menu(
'all_datasource_access', 'all_datasource_access')
sm.add_permission_view_menu('all_database_access', 'all_database_access')
merge_perm(sm, 'all_datasource_access', 'all_datasource_access')
merge_perm(sm, 'all_database_access', 'all_database_access')

perms = db.session.query(ab_models.PermissionView).all()
perms = [p for p in perms if p.permission and p.view_menu]
Expand Down Expand Up @@ -202,10 +201,9 @@ def sync_role_definitions():
o for o in session.query(models.DruidDatasource).all()]
for datasource in datasources:
perm = datasource.get_perm()
sm.add_permission_view_menu('datasource_access', perm)
merge_perm(sm, 'datasource_access', perm)
if datasource.schema:
sm.add_permission_view_menu(
'schema_access', datasource.schema_perm)
merge_perm(sm, 'schema_access', datasource.schema_perm)
if perm != datasource.perm:
datasource.perm = perm

Expand All @@ -215,7 +213,7 @@ def sync_role_definitions():
perm = database.get_perm()
if perm != database.perm:
database.perm = perm
sm.add_permission_view_menu('database_access', perm)
merge_perm(sm, 'database_access', perm)
session.commit()

logging.info("Making sure all metrics perms exist")
Expand Down

0 comments on commit 09d597f

Please sign in to comment.