fix: tags features flag on base models (#23548)
This commit is contained in:
parent
d966db61af
commit
a4d4084d08
|
|
@ -149,14 +149,13 @@ class Dashboard(Model, AuditMixinNullable, ImportExportMixin):
|
|||
Slice, secondary=dashboard_slices, backref="dashboards"
|
||||
)
|
||||
owners = relationship(security_manager.user_model, secondary=dashboard_user)
|
||||
if is_feature_enabled("TAGGING_SYSTEM"):
|
||||
tags = relationship(
|
||||
"Tag",
|
||||
secondary="tagged_object",
|
||||
primaryjoin="and_(Dashboard.id == TaggedObject.object_id)",
|
||||
secondaryjoin="and_(TaggedObject.tag_id == Tag.id, "
|
||||
"TaggedObject.object_type == 'dashboard')",
|
||||
)
|
||||
tags = relationship(
|
||||
"Tag",
|
||||
secondary="tagged_object",
|
||||
primaryjoin="and_(Dashboard.id == TaggedObject.object_id)",
|
||||
secondaryjoin="and_(TaggedObject.tag_id == Tag.id, "
|
||||
"TaggedObject.object_type == 'dashboard')",
|
||||
)
|
||||
published = Column(Boolean, default=False)
|
||||
is_managed_externally = Column(Boolean, nullable=False, default=False)
|
||||
external_url = Column(Text, nullable=True)
|
||||
|
|
|
|||
|
|
@ -96,14 +96,13 @@ class Slice( # pylint: disable=too-many-public-methods
|
|||
security_manager.user_model, foreign_keys=[last_saved_by_fk]
|
||||
)
|
||||
owners = relationship(security_manager.user_model, secondary=slice_user)
|
||||
if is_feature_enabled("TAGGING_SYSTEM"):
|
||||
tags = relationship(
|
||||
"Tag",
|
||||
secondary="tagged_object",
|
||||
primaryjoin="and_(Slice.id == TaggedObject.object_id)",
|
||||
secondaryjoin="and_(TaggedObject.tag_id == Tag.id, "
|
||||
"TaggedObject.object_type == 'chart')",
|
||||
)
|
||||
tags = relationship(
|
||||
"Tag",
|
||||
secondary="tagged_object",
|
||||
primaryjoin="and_(Slice.id == TaggedObject.object_id)",
|
||||
secondaryjoin="and_(TaggedObject.tag_id == Tag.id, "
|
||||
"TaggedObject.object_type == 'chart')",
|
||||
)
|
||||
table = relationship(
|
||||
"SqlaTable",
|
||||
foreign_keys=[datasource_id],
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ from sqlalchemy import (
|
|||
from sqlalchemy.engine.url import URL
|
||||
from sqlalchemy.orm import backref, relationship
|
||||
|
||||
from superset import is_feature_enabled, security_manager
|
||||
from superset import security_manager
|
||||
from superset.jinja_context import BaseTemplateProcessor, get_template_processor
|
||||
from superset.models.helpers import (
|
||||
AuditMixinNullable,
|
||||
|
|
@ -366,14 +366,13 @@ class SavedQuery(Model, AuditMixinNullable, ExtraJSONMixin, ImportExportMixin):
|
|||
)
|
||||
rows = Column(Integer, nullable=True)
|
||||
last_run = Column(DateTime, nullable=True)
|
||||
if is_feature_enabled("TAGGING_SYSTEM"):
|
||||
tags = relationship(
|
||||
"Tag",
|
||||
secondary="tagged_object",
|
||||
primaryjoin="and_(SavedQuery.id == TaggedObject.object_id)",
|
||||
secondaryjoin="and_(TaggedObject.tag_id == Tag.id, "
|
||||
"TaggedObject.object_type == 'saved_query')",
|
||||
)
|
||||
tags = relationship(
|
||||
"Tag",
|
||||
secondary="tagged_object",
|
||||
primaryjoin="and_(SavedQuery.id == TaggedObject.object_id)",
|
||||
secondaryjoin="and_(TaggedObject.tag_id == Tag.id, "
|
||||
"TaggedObject.object_type == 'saved_query')",
|
||||
)
|
||||
|
||||
export_parent = "database"
|
||||
export_fields = [
|
||||
|
|
|
|||
|
|
@ -830,6 +830,7 @@ class TestChartApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixin):
|
|||
],
|
||||
"params": None,
|
||||
"slice_name": "title",
|
||||
"tags": [],
|
||||
"viz_type": None,
|
||||
"query_context": None,
|
||||
"is_managed_externally": False,
|
||||
|
|
|
|||
|
|
@ -434,6 +434,7 @@ class TestDashboardApi(SupersetTestCase, ApiOwnersTestCaseMixin, InsertChartMixi
|
|||
"published": False,
|
||||
"url": "/superset/dashboard/slug1/",
|
||||
"slug": "slug1",
|
||||
"tags": [],
|
||||
"thumbnail_url": dashboard.thumbnail_url,
|
||||
"is_managed_externally": False,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@ class TestTagsDAO(SupersetTestCase):
|
|||
)
|
||||
)
|
||||
yield tags
|
||||
db.session.commit()
|
||||
|
||||
@pytest.fixture()
|
||||
def create_tagged_objects(self):
|
||||
|
|
@ -121,8 +120,8 @@ class TestTagsDAO(SupersetTestCase):
|
|||
tag_id=tag.id,
|
||||
)
|
||||
)
|
||||
|
||||
yield tagged_objects
|
||||
db.session.commit()
|
||||
|
||||
@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
|
||||
@pytest.mark.usefixtures("with_tagging_system_feature")
|
||||
|
|
@ -297,3 +296,5 @@ class TestTagsDAO(SupersetTestCase):
|
|||
def test_validate_tag_name(self):
|
||||
assert TagDAO.validate_tag_name("example_tag_name") is True
|
||||
assert TagDAO.validate_tag_name("invalid:tag_name") is False
|
||||
db.session.query(TaggedObject).delete()
|
||||
db.session.query(Tag).delete()
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ from tests.integration_tests.fixtures.birth_names_dashboard import (
|
|||
load_birth_names_data,
|
||||
)
|
||||
from tests.integration_tests.fixtures.query_context import get_query_context
|
||||
from tests.integration_tests.fixtures.tags import with_tagging_system_feature
|
||||
from tests.integration_tests.test_app import app
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue