From 0f48ba8fcee7760e2b43694683b77552952ce613 Mon Sep 17 00:00:00 2001 From: ofekisr <35701650+ofekisr@users.noreply.github.com> Date: Thu, 7 Oct 2021 14:03:28 +0300 Subject: [PATCH] chore improve response body (#16974) --- superset/dashboards/filter_sets/api.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/superset/dashboards/filter_sets/api.py b/superset/dashboards/filter_sets/api.py index 24c4e8655f4f7..d4efd40fa41c8 100644 --- a/superset/dashboards/filter_sets/api.py +++ b/superset/dashboards/filter_sets/api.py @@ -90,6 +90,7 @@ class FilterSetRestApi(BaseSupersetModelRestApi): JSON_METADATA_FIELD, ] list_columns = [ + "id", "created_on", "changed_on", "created_by_fk", @@ -101,7 +102,15 @@ class FilterSetRestApi(BaseSupersetModelRestApi): DASHBOARD_ID_FIELD, PARAMS_PROPERTY, ] - show_exclude_columns = [OWNER_OBJECT_FIELD, DASHBOARD_FIELD, JSON_METADATA_FIELD] + show_columns = [ + "id", + NAME_FIELD, + DESCRIPTION_FIELD, + OWNER_TYPE_FIELD, + OWNER_ID_FIELD, + DASHBOARD_ID_FIELD, + PARAMS_PROPERTY, + ] search_columns = ["id", NAME_FIELD, OWNER_ID_FIELD, DASHBOARD_ID_FIELD] base_filters = [[OWNER_ID_FIELD, FilterSetFilter, ""]] @@ -232,7 +241,9 @@ def post(self, dashboard_id: int) -> Response: try: item = self.add_model_schema.load(request.json) new_model = CreateFilterSetCommand(g.user, dashboard_id, item).run() - return self.response(201, id=new_model.id, result=item) + return self.response( + 201, **self.show_model_schema.dump(new_model, many=False) + ) except ValidationError as error: return self.response_400(message=error.messages) except UserIsNotDashboardOwnerError: @@ -302,7 +313,9 @@ def put(self, dashboard_id: int, pk: int) -> Response: try: item = self.edit_model_schema.load(request.json) changed_model = UpdateFilterSetCommand(g.user, dashboard_id, pk, item).run() - return self.response(200, id=changed_model.id, result=item) + return self.response( + 200, **self.show_model_schema.dump(changed_model, many=False) + ) except ValidationError as error: return self.response_400(message=error.messages) except (