Skip to content

Commit

Permalink
fix: always allow tags to be returned via the API (#24060)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh committed May 22, 2023
1 parent c3b96d1 commit 7891cea
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
17 changes: 8 additions & 9 deletions superset/charts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ def ensure_thumbnails_enabled(self) -> Optional[Response]:
"viz_type",
"query_context",
"is_managed_externally",
"tags.id",
"tags.name",
"tags.type",
]
if is_feature_enabled("TAGGING_SYSTEM"):
show_columns += ["tags.id", "tags.name", "tags.type"]

show_select_columns = show_columns + ["table.id"]
list_columns = [
Expand Down Expand Up @@ -192,9 +193,10 @@ def ensure_thumbnails_enabled(self) -> Optional[Response]:
"thumbnail_url",
"url",
"viz_type",
"tags.id",
"tags.name",
"tags.type",
]
if is_feature_enabled("TAGGING_SYSTEM"):
list_columns += ["tags.id", "tags.name", "tags.type"]
list_select_columns = list_columns + ["changed_by_fk", "changed_on"]
order_columns = [
"changed_by.first_name",
Expand Down Expand Up @@ -222,9 +224,8 @@ def ensure_thumbnails_enabled(self) -> Optional[Response]:
"dashboards",
"slice_name",
"viz_type",
"tags",
]
if is_feature_enabled("TAGGING_SYSTEM"):
search_columns += ["tags"]
base_order = ("changed_on", "desc")
base_filters = [["id", ChartFilter, lambda: []]]
search_filters = {
Expand All @@ -235,10 +236,8 @@ def ensure_thumbnails_enabled(self) -> Optional[Response]:
],
"slice_name": [ChartAllTextFilter],
"created_by": [ChartHasCreatedByFilter, ChartCreatedByMeFilter],
"tags": [ChartTagFilter],
}
if is_feature_enabled("TAGGING_SYSTEM"):
search_filters["tags"] = [ChartTagFilter]

# Will just affect _info endpoint
edit_columns = ["slice_name"]
add_columns = edit_columns
Expand Down
4 changes: 3 additions & 1 deletion superset/charts/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from superset import app
from superset.common.chart_data import ChartDataResultFormat, ChartDataResultType
from superset.db_engine_specs.base import builtin_time_grains
from superset.tags.models import TagTypes
from superset.utils import pandas_postprocessing, schema as utils
from superset.utils.core import (
AnnotationType,
Expand Down Expand Up @@ -152,7 +153,7 @@
class TagSchema(Schema):
id = fields.Int()
name = fields.String()
type = fields.String()
type = EnumField(TagTypes, by_value=True)


class ChartEntityResponseSchema(Schema):
Expand Down Expand Up @@ -290,6 +291,7 @@ class ChartPutSchema(Schema):
)
is_managed_externally = fields.Boolean(allow_none=True, dump_default=False)
external_url = fields.String(allow_none=True)
tags = fields.Nested(TagSchema, many=True)


class ChartGetDatasourceObjectDataResponseSchema(Schema):
Expand Down
4 changes: 3 additions & 1 deletion superset/dashboards/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@

from marshmallow import fields, post_load, pre_load, Schema
from marshmallow.validate import Length, ValidationError
from marshmallow_enum import EnumField

from superset.exceptions import SupersetException
from superset.tags.models import TagTypes
from superset.utils import core as utils

get_delete_ids_schema = {"type": "array", "items": {"type": "integer"}}
Expand Down Expand Up @@ -172,7 +174,7 @@ class RolesSchema(Schema):
class TagSchema(Schema):
id = fields.Int()
name = fields.String()
type = fields.String()
type = EnumField(TagTypes, by_value=True)


class DashboardGetResponseSchema(Schema):
Expand Down

0 comments on commit 7891cea

Please sign in to comment.