mirror of
https://github.com/apache/superset.git
synced 2024-09-06 13:57:40 -04:00
fix: dashboard datasources filter None (#14471)
This commit is contained in:
parent
23014e9233
commit
a816655715
@ -171,7 +171,7 @@ class Dashboard( # pylint: disable=too-many-instance-attributes
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def datasources(self) -> Set[BaseDatasource]:
|
def datasources(self) -> Set[BaseDatasource]:
|
||||||
return {slc.datasource for slc in self.slices}
|
return {slc.datasource for slc in self.slices if slc.datasource}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def charts(self) -> List[BaseDatasource]:
|
def charts(self) -> List[BaseDatasource]:
|
||||||
|
@ -100,7 +100,7 @@ class Slice(
|
|||||||
return ConnectorRegistry.sources[self.datasource_type]
|
return ConnectorRegistry.sources[self.datasource_type]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def datasource(self) -> "BaseDatasource":
|
def datasource(self) -> Optional["BaseDatasource"]:
|
||||||
return self.get_datasource
|
return self.get_datasource
|
||||||
|
|
||||||
def clone(self) -> "Slice":
|
def clone(self) -> "Slice":
|
||||||
@ -160,8 +160,9 @@ class Slice(
|
|||||||
def viz(self) -> Optional[BaseViz]:
|
def viz(self) -> Optional[BaseViz]:
|
||||||
form_data = json.loads(self.params)
|
form_data = json.loads(self.params)
|
||||||
viz_class = viz_types.get(self.viz_type)
|
viz_class = viz_types.get(self.viz_type)
|
||||||
if viz_class:
|
datasource = self.datasource
|
||||||
return viz_class(datasource=self.datasource, form_data=form_data)
|
if viz_class and datasource:
|
||||||
|
return viz_class(datasource=datasource, form_data=form_data)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -462,6 +462,10 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
|||||||
form_data, slc = get_form_data(slice_id, use_slice_data=True)
|
form_data, slc = get_form_data(slice_id, use_slice_data=True)
|
||||||
if not slc:
|
if not slc:
|
||||||
return json_error_response("The slice does not exist")
|
return json_error_response("The slice does not exist")
|
||||||
|
|
||||||
|
if not slc.datasource:
|
||||||
|
return json_error_response("The slice's datasource does not exist")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
viz_obj = get_viz(
|
viz_obj = get_viz(
|
||||||
datasource_type=slc.datasource.type,
|
datasource_type=slc.datasource.type,
|
||||||
@ -1709,6 +1713,9 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
|||||||
else get_dashboard_extra_filters(slc.id, dashboard_id)
|
else get_dashboard_extra_filters(slc.id, dashboard_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if not slc.datasource:
|
||||||
|
raise Exception("Slice's datasource does not exist")
|
||||||
|
|
||||||
obj = get_viz(
|
obj = get_viz(
|
||||||
datasource_type=slc.datasource.type,
|
datasource_type=slc.datasource.type,
|
||||||
datasource_id=slc.datasource.id,
|
datasource_id=slc.datasource.id,
|
||||||
|
@ -290,7 +290,7 @@ def get_time_range_endpoints(
|
|||||||
if not slc:
|
if not slc:
|
||||||
slc = db.session.query(Slice).filter_by(id=slice_id).one_or_none()
|
slc = db.session.query(Slice).filter_by(id=slice_id).one_or_none()
|
||||||
|
|
||||||
if slc:
|
if slc and slc.datasource:
|
||||||
endpoints = slc.datasource.database.get_extra().get(
|
endpoints = slc.datasource.database.get_extra().get(
|
||||||
"time_range_endpoints"
|
"time_range_endpoints"
|
||||||
)
|
)
|
||||||
@ -533,7 +533,7 @@ def check_slice_perms(_self: Any, slice_id: int) -> None:
|
|||||||
|
|
||||||
form_data, slc = get_form_data(slice_id, use_slice_data=True)
|
form_data, slc = get_form_data(slice_id, use_slice_data=True)
|
||||||
|
|
||||||
if slc:
|
if slc and slc.datasource:
|
||||||
try:
|
try:
|
||||||
viz_obj = get_viz(
|
viz_obj = get_viz(
|
||||||
datasource_type=slc.datasource.type,
|
datasource_type=slc.datasource.type,
|
||||||
|
Loading…
Reference in New Issue
Block a user