mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Merge pull request #1925 from alphagov/refactored-csv-processing
Bring in refactored CSV processing
This commit is contained in:
@@ -528,29 +528,23 @@ def _check_messages(service_id, template_type, upload_id, preview_row, letters_a
|
||||
back_link = url_for('.send_messages', service_id=service_id, template_id=template.id)
|
||||
choose_time_form = ChooseTimeForm()
|
||||
|
||||
count_of_recipients = len(list(recipients.rows))
|
||||
|
||||
if preview_row < 2:
|
||||
abort(404)
|
||||
|
||||
if preview_row < count_of_recipients + 2:
|
||||
template.values = recipients[preview_row - 2]
|
||||
if preview_row < len(recipients) + 2:
|
||||
template.values = recipients[preview_row - 2].recipient_and_personalisation
|
||||
elif preview_row > 2:
|
||||
abort(404)
|
||||
|
||||
session['upload_data']['notification_count'] = count_of_recipients
|
||||
session['upload_data']['notification_count'] = len(recipients)
|
||||
session['upload_data']['valid'] = not recipients.has_errors
|
||||
return dict(
|
||||
recipients=recipients,
|
||||
template=template,
|
||||
errors=recipients.has_errors,
|
||||
row_errors=get_errors_for_csv(recipients, template.template_type),
|
||||
count_of_recipients=count_of_recipients,
|
||||
count_of_displayed_recipients=(
|
||||
len(list(recipients.initial_annotated_rows_with_errors))
|
||||
if any(recipients.rows_with_errors) and not recipients.missing_column_headers else
|
||||
len(list(recipients.initial_annotated_rows))
|
||||
),
|
||||
count_of_recipients=len(recipients),
|
||||
count_of_displayed_recipients=len(list(recipients.displayed_rows)),
|
||||
original_file_name=session['upload_data'].get('original_file_name'),
|
||||
upload_id=upload_id,
|
||||
form=CsvUploadForm(),
|
||||
|
||||
Reference in New Issue
Block a user