-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow adding URL parameters in via content_for_template()
#579
Comments
Hi @yuriescl, Why does For example, I could add two forms to my base template, one for "Previous" and one for "Next" and they would POST to different endpoints: <!-- form content for the current step here (rendered by Django) --!>
<form method="post" action="/transactions/deposit/webapp/next">
<input type="submit" value="Previous">
</form>
<form method="post" action="/transactions/deposit/webapp/previous">
<input type="submit" value="Next">
</form> Then |
That's a great point. |
@JakeUrban I think there might be an issue with the web browser back/forward buttons when using the session to store the step. |
Hi @yuriescl, you're right, you'd need the GET request to contain an indication that the user went back in that case. We can add a key, if next_form or next_content:
args = {
"transaction_id": transaction.id,
"asset_code": asset.code,
**content_from_anchor.get("url_args", {})
}
if amount:
args["amount"] = amount
if callback:
args["callback"] = callback
url = reverse("get_interactive_deposit")
return redirect(f"{url}?{urlencode(args)}") The limitation with this approach is that we won't be able to add URLs to the initial URL returned from the |
Actually, there would be a way for you to change the initial URL. Polaris provides a try:
url = rdi.interactive_url(
request=request,
transaction=transaction,
asset=asset,
amount=amount,
callback=callback,
)
except NotImplementedError:
pass
else:
# The anchor uses a standalone interactive flow
return redirect(url) You could redirect to |
This creates an infinite redirect loop |
This worked for me:
|
It should be easier to control the URL params, though. |
@yuriescl I'll keep this issue open for adding that functionality, glad to hear you have a temporary workaround though |
content_for_template()
After a few more tests, I see there's an issue when the form is invalid. Polaris won't add my Allowing to add params via |
I couldn't find a way to add query params to the URL during the SEP-24 interactive flow.
form_for_transaction
andcontent_for_template
just allow returning the form and template content, but not set additional URL parameters.It's difficult to add previous/next buttons to the form without setting some URL parameter to identify which part of the flow the user is at the moment.
I'd like to have something like:
sep24/transactions/withdraw/webapp?currentStep=1&transaction_id=...
currentStep
would indicate which form to return.As a workaround, Polaris could, for example, get those extra URL parameters from
content_for_template
, similar to how the template name is set usingtemplate_name
.The text was updated successfully, but these errors were encountered: