You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2019/06/21 21:25:59 UTC
[incubator-superset] branch master updated: [security] [ui] Make
security views use superset's list widget (#7724)
This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 90d156f [security] [ui] Make security views use superset's list widget (#7724)
90d156f is described below
commit 90d156f1866c21991017ca3b061609888539206a
Author: Daniel Vaz Gaspar <da...@gmail.com>
AuthorDate: Fri Jun 21 22:25:48 2019 +0100
[security] [ui] Make security views use superset's list widget (#7724)
---
superset/security.py | 30 +++++++++++++++++++++-
.../superset/fab_overrides/list_role.html | 24 +++++++++++++++++
2 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/superset/security.py b/superset/security.py
index 5129e36..ffaeb1c 100644
--- a/superset/security.py
+++ b/superset/security.py
@@ -19,9 +19,12 @@
import logging
from typing import List
-from flask import g
+from flask import current_app, g
from flask_appbuilder.security.sqla import models as ab_models
from flask_appbuilder.security.sqla.manager import SecurityManager
+from flask_appbuilder.security.views import (
+ PermissionModelView, PermissionViewModelView, RoleModelView, UserModelView)
+from flask_appbuilder.widgets import ListWidget
from sqlalchemy import or_
from superset import sql_parse
@@ -30,6 +33,31 @@ from superset.exceptions import SupersetSecurityException
from superset.utils.core import DatasourceName
+class SupersetSecurityListWidget(ListWidget):
+ """
+ Redeclaring to avoid circular imports
+ """
+ template = 'superset/fab_overrides/list.html'
+
+
+class SupersetRoleListWidget(ListWidget):
+ """
+ Role model view from FAB already uses a custom list widget override
+ So we override the override
+ """
+ template = 'superset/fab_overrides/list_role.html'
+
+ def __init__(self, **kwargs):
+ kwargs['appbuilder'] = current_app.appbuilder
+ super().__init__(**kwargs)
+
+
+UserModelView.list_widget = SupersetSecurityListWidget
+RoleModelView.list_widget = SupersetRoleListWidget
+PermissionViewModelView.list_widget = SupersetSecurityListWidget
+PermissionModelView.list_widget = SupersetSecurityListWidget
+
+
class SupersetSecurityManager(SecurityManager):
READ_ONLY_MODEL_VIEWS = {
'DatabaseAsync',
diff --git a/superset/templates/superset/fab_overrides/list_role.html b/superset/templates/superset/fab_overrides/list_role.html
new file mode 100644
index 0000000..95847f9
--- /dev/null
+++ b/superset/templates/superset/fab_overrides/list_role.html
@@ -0,0 +1,24 @@
+{#
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+#}
+{% extends 'appbuilder/general/widgets/roles/list.html' %}
+
+{% block begin_content scoped %}
+ <div class="table-responsive">
+ <table class="table table-hover">
+{% endblock %}