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

Change hardcoded references to 'User' security model #2728

Merged
merged 2 commits into from
May 12, 2017
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion superset/connectors/druid/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class DruidDatasource(Model, BaseDatasource):
'DruidCluster', backref='datasources', foreign_keys=[cluster_name])
user_id = Column(Integer, ForeignKey('ab_user.id'))
owner = relationship(
'User',
sm.user_model,
backref=backref('datasources', cascade='all, delete-orphan'),
foreign_keys=[user_id])

Expand Down
4 changes: 2 additions & 2 deletions superset/connectors/sqla/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from flask_appbuilder import Model
from flask_babel import lazy_gettext as _

from superset import db, utils, import_util
from superset import db, utils, import_util, sm
from superset.connectors.base import BaseDatasource, BaseColumn, BaseMetric
from superset.utils import DTTM_ALIAS, QueryStatus
from superset.models.helpers import QueryResult
Expand Down Expand Up @@ -169,7 +169,7 @@ class SqlaTable(Model, BaseDatasource):
fetch_values_predicate = Column(String(1000))
user_id = Column(Integer, ForeignKey('ab_user.id'))
owner = relationship(
'User',
sm.user_model,
backref='tables',
foreign_keys=[user_id])
database = relationship(
Expand Down
6 changes: 3 additions & 3 deletions superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Slice(Model, AuditMixinNullable, ImportMixin):
description = Column(Text)
cache_timeout = Column(Integer)
perm = Column(String(1000))
owners = relationship("User", secondary=slice_user)
owners = relationship(sm.user_model, secondary=slice_user)

export_fields = ('slice_name', 'datasource_type', 'datasource_name',
'viz_type', 'params', 'cache_timeout')
Expand Down Expand Up @@ -304,7 +304,7 @@ class Dashboard(Model, AuditMixinNullable, ImportMixin):
slug = Column(String(255), unique=True)
slices = relationship(
'Slice', secondary=dashboard_slices, backref='dashboards')
owners = relationship("User", secondary=dashboard_user)
owners = relationship(sm.user_model, secondary=dashboard_user)

export_fields = ('dashboard_title', 'position_json', 'json_metadata',
'description', 'css', 'slug')
Expand Down Expand Up @@ -728,7 +728,7 @@ class Log(Model):
dashboard_id = Column(Integer)
slice_id = Column(Integer)
json = Column(Text)
user = relationship('User', backref='logs', foreign_keys=[user_id])
user = relationship(sm.user_model, backref='logs', foreign_keys=[user_id])
dttm = Column(DateTime, default=datetime.utcnow)
dt = Column(Date, default=date.today())
duration_ms = Column(Integer)
Expand Down
5 changes: 3 additions & 2 deletions superset/models/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
)
from sqlalchemy.orm import backref, relationship

from superset import sm
from superset.utils import QueryStatus
from superset.models.helpers import AuditMixinNullable

Expand Down Expand Up @@ -79,7 +80,7 @@ class Query(Model):
backref=backref('queries', cascade='all, delete-orphan')
)
user = relationship(
'User',
sm.user_model,
foreign_keys=[user_id])

__table_args__ = (
Expand Down Expand Up @@ -147,7 +148,7 @@ class SavedQuery(Model, AuditMixinNullable):
description = Column(Text)
sql = Column(Text)
user = relationship(
'User',
sm.user_model,
backref=backref('saved_queries', cascade='all, delete-orphan'),
foreign_keys=[user_id])
database = relationship(
Expand Down