Added job row number to the notification for csv jobs. All tests passing.

This commit is contained in:
Nicholas Staples
2016-05-19 10:46:03 +01:00
parent a606f2c97e
commit 0fe0c1d2b4
8 changed files with 81 additions and 15 deletions

View File

@@ -148,17 +148,18 @@ def process_job(job_id):
dao_get_template_by_id(job.template_id, job.template_version).__dict__
)
for recipient, personalisation in RecipientCSV(
for row_number, recipient, personalisation in RecipientCSV(
s3.get_job_from_s3(str(service.id), str(job_id)),
template_type=template.template_type,
placeholders=template.placeholders
).recipients_and_personalisation:
).enumerated_recipients_and_personalisation:
encrypted = encryption.encrypt({
'template': str(template.id),
'template_version': job.template_version,
'job': str(job.id),
'to': recipient,
'row_number': row_number,
'personalisation': {
key: personalisation.get(key)
for key in template.placeholders
@@ -242,6 +243,7 @@ def send_sms(service_id, notification_id, encrypted_notification, created_at):
to=notification['to'],
service_id=service_id,
job_id=notification.get('job', None),
job_row_number=notification.get('row_number', None),
status='failed' if restricted else 'sending',
created_at=datetime.strptime(created_at, DATETIME_FORMAT),
sent_at=sent_at,
@@ -307,6 +309,7 @@ def send_email(service_id, notification_id, from_address, encrypted_notification
to=notification['to'],
service_id=service_id,
job_id=notification.get('job', None),
job_row_number=notification.get('row_number', None),
status='failed' if restricted else 'sending',
created_at=datetime.strptime(created_at, DATETIME_FORMAT),
sent_at=sent_at,