Skip to content

Commit

Permalink
fix related fields
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgaspar committed Dec 17, 2020
1 parent f9cc5bd commit eed30f2
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions superset/reports/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from superset.charts.filters import ChartFilter
from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
from superset.dashboards.filters import DashboardFilter
from superset.databases.filters import DatabaseFilter
from superset.models.reports import ReportSchedule
from superset.reports.commands.bulk_delete import BulkDeleteReportScheduleCommand
from superset.reports.commands.create import CreateReportScheduleCommand
Expand All @@ -47,7 +48,12 @@
ReportSchedulePostSchema,
ReportSchedulePutSchema,
)
from superset.views.base_api import BaseSupersetModelRestApi, statsd_metrics
from superset.views.base_api import (
BaseSupersetModelRestApi,
RelatedFieldFilter,
statsd_metrics,
)
from superset.views.filters import FilterRelatedOwners

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -155,12 +161,23 @@ class ReportScheduleRestApi(BaseSupersetModelRestApi):
]
search_columns = ["name", "active", "created_by", "type", "last_state"]
search_filters = {"name": [ReportScheduleAllTextFilter]}
allowed_rel_fields = {"created_by", "chart", "dashboard"}
allowed_rel_fields = {"owners", "chart", "dashboard", "database"}
filter_rel_fields = {
"chart": [["id", ChartFilter, lambda: []]],
"dashboard": [["id", DashboardFilter, lambda: []]],
"database": [["id", DatabaseFilter, lambda: []]],
}
text_field_rel_fields = {
"dashboard": "dashboard_title",
"chart": "slice_name",
"database": "database_name",
}
related_field_filters = {
"dashboard": "dashboard_title",
"chart": "slice_name",
"database": "database_name",
"owners": RelatedFieldFilter("first_name", FilterRelatedOwners),
}
text_field_rel_fields = {"dashboard": "dashboard_title"}

apispec_parameter_schemas = {
"get_delete_ids_schema": get_delete_ids_schema,
Expand Down

0 comments on commit eed30f2

Please sign in to comment.