You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@superset.apache.org by GitBox <gi...@apache.org> on 2017/11/15 16:39:47 UTC

[GitHub] mistercrunch closed pull request #3875: [SqlLab] Filter out unavailable databases

mistercrunch closed pull request #3875: [SqlLab] Filter out unavailable databases
URL: https://github.com/apache/incubator-superset/pull/3875
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/views/core.py b/superset/views/core.py
index e5ae70846e..bebf17fd23 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -130,6 +130,14 @@ def apply(self, query, func):  # noqa
         return query.filter(self.model.perm.in_(perms))
 
 
+class DatabaseFilter(SupersetFilter):
+    def apply(self, query, func):
+        if self.has_all_datasource_access():
+            return query
+        perms = self.get_view_menus('database_access')
+        return query.filter(self.model.perm.in_(perms))
+
+
 class DashboardFilter(SupersetFilter):
 
     """List dashboards for which users have access to at least one slice"""
@@ -203,6 +211,7 @@ class DatabaseView(SupersetModelView, DeleteMixin):  # noqa
     ]
     add_template = 'superset/models/database/add.html'
     edit_template = 'superset/models/database/edit.html'
+    base_filters = [['perm', DatabaseFilter, lambda:[]]]
     base_order = ('changed_on', 'desc')
     description_columns = {
         'sqlalchemy_uri': utils.markdown(


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services