mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-17 11:49:21 -04:00
Explain 3 required address columns
Our rules about address columns are relaxing, so that none of them are mandatory any more. Instead you just need any 3 of the 7 to make a valid address. This commit updates our error messaging to reflect that.
This commit is contained in:
@@ -19,13 +19,8 @@ from notifications_utils import LETTER_MAX_PAGE_COUNT, SMS_CHAR_COUNT_LIMIT
|
||||
from notifications_utils.columns import Columns
|
||||
from notifications_utils.pdf import is_letter_too_long
|
||||
from notifications_utils.postal_address import PostalAddress
|
||||
from notifications_utils.recipients import (
|
||||
RecipientCSV,
|
||||
first_column_headings,
|
||||
optional_address_columns,
|
||||
)
|
||||
from notifications_utils.recipients import RecipientCSV, first_column_headings
|
||||
from notifications_utils.sanitise_text import SanitiseASCII
|
||||
from orderedset import OrderedSet
|
||||
from xlrd.biffh import XLRDError
|
||||
from xlrd.xldate import XLDateError
|
||||
|
||||
@@ -663,9 +658,7 @@ def _check_messages(service_id, template_id, upload_id, preview_row, letters_as_
|
||||
)
|
||||
recipients = RecipientCSV(
|
||||
contents,
|
||||
template_type=template.template_type,
|
||||
template=template,
|
||||
placeholders=template.placeholders,
|
||||
max_initial_rows_shown=50,
|
||||
max_errors_shown=50,
|
||||
whitelist=itertools.chain.from_iterable(
|
||||
@@ -711,7 +704,7 @@ def _check_messages(service_id, template_id, upload_id, preview_row, letters_as_
|
||||
current_service.trial_mode,
|
||||
template.template_type == 'letter',
|
||||
)),
|
||||
required_recipient_columns=OrderedSet(recipients.recipient_column_headers) - optional_address_columns,
|
||||
first_recipient_column=recipients.recipient_column_headers[0],
|
||||
preview_row=preview_row,
|
||||
sent_previously=job_api_client.has_sent_previously(
|
||||
service_id, template.id, db_template['version'], request.args.get('original_file_name', '')
|
||||
|
||||
@@ -43,6 +43,7 @@ from app.utils import (
|
||||
generate_previous_dict,
|
||||
get_errors_for_csv,
|
||||
get_letter_validation_error,
|
||||
get_sample_template,
|
||||
get_template,
|
||||
unicode_truncate,
|
||||
user_has_permissions,
|
||||
@@ -357,7 +358,7 @@ def check_contact_list(service_id, upload_id):
|
||||
|
||||
recipients = RecipientCSV(
|
||||
contents,
|
||||
template_type=template_type or 'sms',
|
||||
template=get_sample_template(template_type or 'sms'),
|
||||
whitelist=itertools.chain.from_iterable(
|
||||
[user.name, user.mobile_number, user.email_address]
|
||||
for user in current_service.active_users
|
||||
|
||||
@@ -14,6 +14,7 @@ from app.s3_client.s3_csv_client import (
|
||||
s3upload,
|
||||
set_metadata_on_csv_upload,
|
||||
)
|
||||
from app.utils import get_sample_template
|
||||
|
||||
|
||||
class ContactList(JSONModel):
|
||||
@@ -119,7 +120,7 @@ class ContactList(JSONModel):
|
||||
def recipients(self):
|
||||
return RecipientCSV(
|
||||
self.contents,
|
||||
template_type=self.template_type,
|
||||
template=get_sample_template(self.template_type),
|
||||
international_sms=True,
|
||||
max_initial_rows_shown=50,
|
||||
)
|
||||
|
||||
@@ -58,15 +58,16 @@
|
||||
<h1 class='banner-title' data-module="track-error" data-error-type="Missing recipient columns" data-error-label="{{ upload_id }}">
|
||||
There’s a problem with your column names
|
||||
</h1>
|
||||
{% if template.template_type == 'letter' %}
|
||||
<p>
|
||||
Your file needs {{ (
|
||||
recipients.missing_column_headers
|
||||
if template.template_type == 'letter' else required_recipient_columns
|
||||
) | formatted_list(
|
||||
prefix='a column called',
|
||||
prefix_plural='columns called'
|
||||
) }}.
|
||||
Your file needs at least 3 address columns, for example ‘address line 1’,
|
||||
‘address line 2’ and ‘address line 3’.
|
||||
</p>
|
||||
{% else %}
|
||||
<p>
|
||||
Your file needs a column called ‘{{ first_recipient_column }}’.
|
||||
</p>
|
||||
{% endif %}
|
||||
<p>
|
||||
Right now it has {{ recipients.column_headers | formatted_list(
|
||||
prefix='one column, called ',
|
||||
|
||||
11
app/utils.py
11
app/utils.py
@@ -151,6 +151,15 @@ def get_errors_for_csv(recipients, template_type):
|
||||
return errors
|
||||
|
||||
|
||||
def get_sample_template(template_type):
|
||||
if template_type == 'email':
|
||||
return EmailPreviewTemplate({'content': 'any', 'subject': '', 'template_type': 'email'})
|
||||
if template_type == 'sms':
|
||||
return SMSPreviewTemplate({'content': 'any', 'template_type': 'sms'})
|
||||
if template_type == 'letter':
|
||||
return LetterImageTemplate({'content': 'any', 'subject': '', 'template_type': 'letter'})
|
||||
|
||||
|
||||
def generate_notifications_csv(**kwargs):
|
||||
from app import notification_api_client
|
||||
from app.s3_client.s3_csv_client import s3download
|
||||
@@ -161,7 +170,7 @@ def generate_notifications_csv(**kwargs):
|
||||
original_file_contents = s3download(kwargs['service_id'], kwargs['job_id'])
|
||||
original_upload = RecipientCSV(
|
||||
original_file_contents,
|
||||
template_type=kwargs['template_type'],
|
||||
template=get_sample_template(kwargs['template_type']),
|
||||
)
|
||||
original_column_headers = original_upload.column_headers
|
||||
fieldnames = ['Row number'] + original_column_headers + ['Template', 'Type', 'Job', 'Status', 'Time']
|
||||
|
||||
Reference in New Issue
Block a user