Skip to content

Commit

Permalink
Fixed bug where, if an error occurs, the 'Download or Display' option…
Browse files Browse the repository at this point in the history
… doesn't have a default value set - therefore allowing a user to submit a form with no valid radio state.
  • Loading branch information
Felixim0 committed Nov 11, 2024
1 parent 7217aec commit 44d0044
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
9 changes: 6 additions & 3 deletions src/aims_ui/models/get_fields.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from .field import Field
from .endpoint_options import get_options
from flask import url_for

from aims_ui import get_epoch_options_cached

from .endpoint_options import get_options
from .field import Field

# This will change when DS changes
hidden_field_class = ' ons-u-hidden '

Expand Down Expand Up @@ -292,6 +294,7 @@ def get_fields(endpoint_name, include_UPRN_redirect=False):
search_type='radio',
flag=False,
display_title='How would you like your results?',
default_radio_selection='Download',
radio_options=[
{
'id': 'Download',
Expand Down Expand Up @@ -323,7 +326,7 @@ def get_fields(endpoint_name, include_UPRN_redirect=False):
),
Field(
'name',
display_title="Name (Optinal)",
display_title="Name (Optional)",
description='Optional tag to organise matches',
previous_value='',
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from .utils.multiple_match_file_upload_utils import check_valid_upload
from .utils.submit_multiple_match_from_singlesearch import (
multiple_address_match_from_singlesearch_display,
multiple_address_match_from_singlesearch_download)
multiple_address_match_from_singlesearch_download
)

page_name = 'multiple_address_original'

Expand Down Expand Up @@ -80,11 +81,6 @@ def multiple_address_original():

if request.method == 'GET':
delete_input(session)
# Set default selected radio
for field in searchable_fields:
if field.database_name == 'display-type':
field.set_radio_status('Download')

return render_template(
page_location,
searchable_fields=searchable_fields,
Expand All @@ -109,6 +105,7 @@ def multiple_address_original():
e.error_description)

if not file_valid:
print('FILE IS NOT VALID')
return page_error_annotation_multiple(page_name, all_user_input,
error_description)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def convert_exception_to_error_message(primary_error_message):
if isinstance(primary_error_message, Exception):
primary_error_message = str(primary_error_message)

if 'Expecting value: line 2 column 1':
if 'Expecting value: line 2 column 1' in primary_error_message:
# Error message when there's a connection error to the API
return 'Connection error to the API'

Expand Down

0 comments on commit 44d0044

Please sign in to comment.