Skip to content

Commit

Permalink
Merge pull request #1276 from GSA/notify-admin-1237
Browse files Browse the repository at this point in the history
Use USWDS error formatting for file too big error (notify-admin-1237)
  • Loading branch information
ccostino authored Mar 11, 2024
2 parents bdea60a + 68163aa commit e914885
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,11 @@ class CsvUploadForm(StripWhitespaceForm):
validators=[
DataRequired(message="Please pick a file"),
CsvFileValidator(),
FileSize(max_size=10e6, message="File must be smaller than 10Mb"), # 10Mb
FileSize(
max_size=10e6,
message="File must be smaller than 10Mb. If you are trying to upload an Excel file, \
please export the contents in the CSV format and then try again.",
), # 10Mb
],
)

Expand Down
8 changes: 6 additions & 2 deletions app/main/views/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from flask import abort, flash, redirect, render_template, request, session, url_for
from flask_login import current_user
from markupsafe import Markup
from notifications_python_client.errors import HTTPError
from notifications_utils import SMS_CHAR_COUNT_LIMIT
from notifications_utils.insensitive_dict import InsensitiveDict
Expand Down Expand Up @@ -151,8 +152,11 @@ def send_messages(service_id, template_id):
# just show the first error, as we don't expect the form to have more
# than one, since it only has one field
first_field_errors = list(form.errors.values())[0]
flash(first_field_errors[0])

error_message = '<span class="usa-error-message">'
error_message = f"{error_message}{first_field_errors[0]}"
error_message = f"{error_message}</span>"
error_message = Markup(error_message)
flash(error_message)
column_headings = get_spreadsheet_column_headings_from_template(template)

return render_template(
Expand Down

0 comments on commit e914885

Please sign in to comment.