Skip to content

Commit

Permalink
Let user choose which version of Notify docs they want to view
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
CrystalPea committed Oct 3, 2024
1 parent 42483fc commit 23f3733
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/main/views/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 8 additions & 0 deletions tests/app/main/views/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

0 comments on commit 23f3733

Please sign in to comment.