Skip to content

Commit

Permalink
Revert PR #6933 (#7162)
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida authored Mar 28, 2019
1 parent 87fb2df commit b7fb15f
Showing 1 changed file with 5 additions and 28 deletions.
33 changes: 5 additions & 28 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from flask import (
abort, flash, g, Markup, redirect, render_template, request, Response, url_for,
)
from flask_appbuilder import expose, Model, SimpleFormView
from flask_appbuilder import expose, SimpleFormView
from flask_appbuilder.actions import action
from flask_appbuilder.models.sqla.interface import SQLAInterface
from flask_appbuilder.security.decorators import has_access, has_access_api
Expand All @@ -36,8 +36,7 @@
import pandas as pd
import simplejson as json
import sqlalchemy as sqla
from sqlalchemy import (
and_, Column, create_engine, ForeignKey, Integer, MetaData, or_, Table, update)
from sqlalchemy import and_, create_engine, MetaData, or_, update
from sqlalchemy.engine.url import make_url
from sqlalchemy.exc import IntegrityError
from werkzeug.routing import BaseConverter
Expand Down Expand Up @@ -101,30 +100,13 @@ def is_owner(obj, user):
return obj and user in obj.owners


SQLTable = Table(
'tables',
Model.metadata, # pylint: disable=no-member
Column('id', Integer, primary_key=True),
Column('database_id', Integer, ForeignKey('dbs.id')),
extend_existing=True)


class SliceFilter(SupersetFilter):
def apply(self, query, func): # noqa
if security_manager.all_datasource_access():
return query

perms = self.get_view_menus('datasource_access')
# TODO(bogdan): add `schema_access` support here
datasource_perms = self.get_view_menus('datasource_access')
query = (
query.outerjoin(SQLTable, self.model.datasource_id == SQLTable.c.id)
.outerjoin(models.Database, models.Database.id == SQLTable.c.database_id)
.filter(or_(
models.Database.perm.in_(datasource_perms),
self.model.perm.in_(datasource_perms),
))
)
return query
return query.filter(self.model.perm.in_(perms))


class DashboardFilter(SupersetFilter):
Expand All @@ -142,12 +124,7 @@ def apply(self, query, func): # noqa
slice_ids_qry = (
db.session
.query(Slice.id)
.outerjoin(SQLTable, Slice.datasource_id == SQLTable.c.id)
.outerjoin(models.Database, models.Database.id == SQLTable.c.database_id)
.filter(or_(
models.Database.perm.in_(datasource_perms),
Slice.perm.in_(datasource_perms),
))
.filter(Slice.perm.in_(datasource_perms))
)
owner_ids_qry = (
db.session
Expand Down

0 comments on commit b7fb15f

Please sign in to comment.