From 23f37332cefbe43d1d4f7e92b2a8664e0d1b1fb0 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 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", + )