Merge pull request #3276 from alphagov/letter-error-display

handle invalid upload errors correctly
This commit is contained in:
Leo Hemsted
2020-01-27 15:31:32 +00:00
committed by GitHub
2 changed files with 5 additions and 3 deletions

View File

@@ -629,13 +629,15 @@ LETTER_VALIDATION_MESSAGES = {
def get_letter_validation_error(validation_message, invalid_pages=None, page_count=None):
if not invalid_pages:
invalid_pages = []
if validation_message not in LETTER_VALIDATION_MESSAGES:
return {'title': 'Validation failed'}
invalid_pages_are_or_is = 'is' if len(invalid_pages) == 1 else 'are'
invalid_pages = unescaped_formatted_list(
invalid_pages or [],
invalid_pages,
before_each='',
after_each='',
prefix='page',

View File

@@ -458,7 +458,7 @@ def test_get_letter_validation_error_for_unknown_error():
),
(
'letter-too-long',
[2],
None,
'Your letter is too long',
(
'Letters must be 10 pages or less. '
@@ -471,7 +471,7 @@ def test_get_letter_validation_error_for_unknown_error():
),
(
'unable-to-read-the-file',
[2],
None,
'Theres a problem with your file',
(
'Notify cannot read this PDF.'