michael-s-molina commented on code in PR #21469:
URL: https://github.com/apache/superset/pull/21469#discussion_r971121480
##########
superset/views/core.py:
##########
@@ -736,6 +738,40 @@ def import_dashboards(self) -> FlaskResponse:
"superset/import_dashboards.html", databases=databases
)
+ def get_redirect_url(self) -> str:
+ """Assembles the redirect URL to the new endpoint. It also replaces
+ the form_data param with a form_data_key by saving the original content
+ to the cache layer.
+ """
+ redirect_url = request.url.replace("/superset/explore", "/explore")
+ form_data_key = None
+ request_form_data = request.args.get("form_data")
+ if request_form_data:
+ parsed_form_data = loads_request_json(request_form_data)
+ slice_id = parsed_form_data.get(
+ "slice_id", int(request.args.get("slice_id", 0))
+ )
+ datasource = parsed_form_data.get("datasource")
+ if datasource:
+ parts = datasource.split("__")
+ datasource_id = parts[0]
+ datasource_type = parts[1]
+ parameters = CommandParameters(
+ datasource_id=datasource_id,
+ datasource_type=datasource_type,
+ chart_id=slice_id,
+ form_data=request_form_data,
+ )
+ form_data_key = CreateFormDataCommand(parameters).run()
+ if form_data_key:
+ url = parse.urlparse(redirect_url)
+ query = parse.parse_qs(url.query)
+ query.pop("form_data")
+ query["form_data_key"] = [form_data_key]
Review Comment:
From
[urllib.parse](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.parse_qs)
> The dictionary keys are the unique query variable names and the values are
lists of values for each name.
It's because most web frameworks allow multiple values to be associated with
a single field.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]