From 4fecb24a0931047f7b484a41515043ee01084bbf Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Thu, 3 Oct 2024 11:47:23 +0100 Subject: [PATCH] Let user choose which version of Notify docs they want to view When sending them a link to a particular section in the docs. We do this as often when sending service users links to a section in the docs, we don't know which of our clients they use, if any. I also included "Any is fine" option to choose, for users who aren't very technical, but would still like to see the docs. It might be hard for these users to choose from a list of options they are not familiar with. Hence, I provided a "comfort" option for them. Selecting this will take them to rest API docs. --- app/main/views/index.py | 9 ++++++++- tests/app/main/views/test_index.py | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/main/views/index.py b/app/main/views/index.py index 6f8c864d5c..13e5cf2b01 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 29c45f80ea..2442d15a0d 100644 --- a/tests/app/main/views/test_index.py +++ b/tests/app/main/views/test_index.py @@ -459,3 +459,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", + )