Skip to content

Commit

Permalink
Pass the section tag in form's hidden field - so it's available for P…
Browse files Browse the repository at this point in the history
…OST request
  • Loading branch information
CrystalPea committed Oct 3, 2024
1 parent 720318d commit cde01bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2304,6 +2304,10 @@ def check_url(self, *args, **kwargs):


class ChooseDocsForm(StripWhitespaceForm):

def __init__(self, section_tag):
super().__init__(section_tag=section_tag)

docs_version = GovukRadiosField(
"Which version of the docs would you like to view?",
choices=[
Expand All @@ -2318,6 +2322,7 @@ class ChooseDocsForm(StripWhitespaceForm):
],
thing="a language version of GOV.UK Notify's API docs",
)
section_tag = HiddenField("section tag")


class SMSPrefixForm(StripWhitespaceForm):
Expand Down
2 changes: 1 addition & 1 deletion app/main/views/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def guidance_api_documentation_section():

@main.route("/using-notify/api-documentation/section/choose-docs")
def guidance_api_documentation_section_choose_docs():
form = ChooseDocsForm()
form = ChooseDocsForm(section_tag=request.args.get("section_tag"))
return render_template(
"views/guidance/using-notify/api-documentation-section-choose-docs.html",
navigation_links=using_notify_nav(),
Expand Down
5 changes: 5 additions & 0 deletions tests/app/main/views/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,8 @@ def test_GET_guidance_api_documentation_section_choose_docs(client_request):
assert ["python", "ruby", "java", "node", "net", "php", "rest-api", "rest-api"] == [
radio["value"] for radio in page.select("input[type=radio]")
]
form = page.select_one("form")
assert form["action"] == url_for(
"main.guidance_api_documentation_section_choose_docs",
section_tag="send-a-file-by-email",
)

0 comments on commit cde01bf

Please sign in to comment.