Use RecipientCSV from utils for processing CSVs

See https://github.com/alphagov/notifications-utils/pull/9 for details of the
changes.
This commit is contained in:
Chris Hill-Scott
2016-03-06 12:51:45 +00:00
parent e99331315e
commit 7cb8450839
2 changed files with 8 additions and 7 deletions

View File

@@ -12,7 +12,7 @@ from sqlalchemy.exc import SQLAlchemyError
from app.aws import s3 from app.aws import s3
from datetime import datetime from datetime import datetime
from utils.template import Template from utils.template import Template
from utils.process_csv import get_rows_from_csv, get_recipient_from_row, first_column_heading from utils.recipients import RecipientCSV, first_column_heading
@notify_celery.task(name="process-job") @notify_celery.task(name="process-job")
@@ -22,15 +22,16 @@ def process_job(job_id):
job.status = 'in progress' job.status = 'in progress'
dao_update_job(job) dao_update_job(job)
file = s3.get_job_from_s3(job.bucket_name, job_id) for recipient, personalisation in RecipientCSV(
s3.get_job_from_s3(job.bucket_name, job_id),
for row in get_rows_from_csv(file): template_type=job.template.template_type
).recipients_and_personalisation:
encrypted = encryption.encrypt({ encrypted = encryption.encrypt({
'template': job.template_id, 'template': job.template_id,
'job': str(job.id), 'job': str(job.id),
'to': get_recipient_from_row(row, job.template.template_type), 'to': recipient,
'personalisation': row 'personalisation': personalisation
}) })
if job.template.template_type == 'sms': if job.template.template_type == 'sms':

View File

@@ -21,4 +21,4 @@ monotonic==0.3
git+https://github.com/alphagov/notifications-python-client.git@0.2.6#egg=notifications-python-client==0.2.6 git+https://github.com/alphagov/notifications-python-client.git@0.2.6#egg=notifications-python-client==0.2.6
git+https://github.com/alphagov/notifications-utils.git@1.0.0#egg=notifications-utils==1.0.0 git+https://github.com/alphagov/notifications-utils.git@2.0.0#egg=notifications-utils==2.0.0