diff --git a/app/main/views/index.py b/app/main/views/index.py index 6f8c864d5c0..13e5cf2b01b 100644 --- a/app/main/views/index.py +++ b/app/main/views/index.py @@ -175,9 +175,16 @@ def guidance_api_documentation_section(): ) -@main.route("/using-notify/api-documentation/section/choose-docs") +@main.route("/using-notify/api-documentation/section/choose-docs", methods=["GET", "POST"]) def guidance_api_documentation_section_choose_docs(): form = ChooseDocsForm(section_tag=request.args.get("section_tag")) + + if form.validate_on_submit(): + redirect_url = ( + f"https://docs.notifications.service.gov.uk/{form.docs_version.data}.html#{form.section_tag.data}" + ) + return redirect(redirect_url) + return render_template( "views/guidance/using-notify/api-documentation-section-choose-docs.html", navigation_links=using_notify_nav(), diff --git a/tests/app/main/views/test_index.py b/tests/app/main/views/test_index.py index 4c25d28a09d..1734a051ba6 100644 --- a/tests/app/main/views/test_index.py +++ b/tests/app/main/views/test_index.py @@ -445,3 +445,11 @@ def test_GET_guidance_api_documentation_section_choose_docs(client_request): "main.guidance_api_documentation_section_choose_docs", section_tag="send-a-file-by-email", ) + + +def test_POST_guidance_api_documentation_section_choose_docs(client_request): + client_request.post( + "main.guidance_api_documentation_section_choose_docs", + _data={"docs_version": "python", "section_tag": "send-a-file-by-email"}, + _expected_redirect="https://docs.notifications.service.gov.uk/python.html#send-a-file-by-email", + )