Skip to content

Commit 5c7de42

Browse files
committed
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.
1 parent c5e9dd0 commit 5c7de42

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app/main/views/index.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,16 @@ def guidance_api_documentation_section():
175175
)
176176

177177

178-
@main.route("/using-notify/api-documentation/section/choose-docs")
178+
@main.route("/using-notify/api-documentation/section/choose-docs", methods=["GET", "POST"])
179179
def guidance_api_documentation_section_choose_docs():
180180
form = ChooseDocsForm(section_tag=request.args.get("section_tag"))
181+
182+
if form.validate_on_submit():
183+
redirect_url = (
184+
f"https://docs.notifications.service.gov.uk/{form.docs_version.data}.html#{form.section_tag.data}"
185+
)
186+
return redirect(redirect_url)
187+
181188
return render_template(
182189
"views/guidance/using-notify/api-documentation-section-choose-docs.html",
183190
navigation_links=using_notify_nav(),

tests/app/main/views/test_index.py

+8
Original file line numberDiff line numberDiff line change
@@ -445,3 +445,11 @@ def test_GET_guidance_api_documentation_section_choose_docs(client_request):
445445
"main.guidance_api_documentation_section_choose_docs",
446446
section_tag="send-a-file-by-email",
447447
)
448+
449+
450+
def test_POST_guidance_api_documentation_section_choose_docs(client_request):
451+
client_request.post(
452+
"main.guidance_api_documentation_section_choose_docs",
453+
_data={"docs_version": "python", "section_tag": "send-a-file-by-email"},
454+
_expected_redirect="https://docs.notifications.service.gov.uk/python.html#send-a-file-by-email",
455+
)

0 commit comments

Comments
 (0)