Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert PR #6933 #7162

Merged
merged 1 commit into from
Mar 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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