Skip to content

Commit

Permalink
Change hardcoded references to 'User' security model to allow custom …
Browse files Browse the repository at this point in the history
…class override (#2728)
  • Loading branch information
RichRadics authored and mistercrunch committed May 12, 2017
1 parent d79a45f commit 91d951a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
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

0 comments on commit 91d951a

Please sign in to comment.