Use the notification types enum for the notifications.notification_type.

Reuse EMAIL_TYPE in template_types and notification_types.
This commit is contained in:
Rebecca Law
2016-06-29 11:50:54 +01:00
parent 60e159e3c0
commit 25db1bce74
6 changed files with 35 additions and 27 deletions

View File

@@ -23,6 +23,8 @@ from notifications_utils.template import (
unlink_govuk_escaped
)
from app.models import SMS_TYPE
def retry_iteration_to_delay(retry=0):
"""
@@ -75,7 +77,7 @@ def send_sms_to_provider(self, service_id, notification_id, encrypted_notificati
update_provider_stats(
notification_id,
'sms',
SMS_TYPE,
provider.get_name(),
content_char_count=template.replaced_content_count
)

View File

@@ -4,6 +4,8 @@ from flask import current_app
from app import notify_celery
from requests import request, RequestException, HTTPError
from app.models import SMS_TYPE
temp_fail = "07833333333"
perm_fail = "07822222222"
delivered = "07811111111"
@@ -21,7 +23,7 @@ def send_sms_response(provider, reference, to):
else:
headers = {"Content-type": "application/x-www-form-urlencoded"}
body = firetext_callback(reference, to)
make_request('sms', provider, body, headers)
make_request(SMS_TYPE, provider, body, headers)
@notify_celery.task(name="send-ses-response")

View File

@@ -37,8 +37,8 @@ from app.dao.services_dao import dao_fetch_service_by_id
from app.dao.templates_dao import dao_get_template_by_id
from app.models import (
Notification,
TEMPLATE_TYPE_EMAIL,
TEMPLATE_TYPE_SMS
EMAIL_TYPE,
SMS_TYPE
)
@@ -94,7 +94,7 @@ def process_job(job_id):
}
})
if template.template_type == 'sms':
if template.template_type == SMS_TYPE:
send_sms.apply_async((
str(job.service_id),
create_uuid(),
@@ -103,7 +103,7 @@ def process_job(job_id):
queue='bulk-sms'
)
if template.template_type == 'email':
if template.template_type == EMAIL_TYPE:
send_email.apply_async((
str(job.service_id),
create_uuid(),
@@ -158,9 +158,9 @@ def send_sms(self, service_id, notification_id, encrypted_notification, created_
status='created',
created_at=datetime.strptime(created_at, DATETIME_FORMAT),
personalisation=notification.get('personalisation'),
notification_type='sms'
notification_type=SMS_TYPE
)
dao_create_notification(notification_db_object, TEMPLATE_TYPE_SMS)
dao_create_notification(notification_db_object, SMS_TYPE)
send_sms_to_provider.apply_async((service_id, notification_id), queue='sms')
@@ -207,7 +207,7 @@ def send_email(service_id, notification_id, encrypted_notification, created_at,
notification_type='email'
)
dao_create_notification(notification_db_object, TEMPLATE_TYPE_EMAIL)
dao_create_notification(notification_db_object, EMAIL_TYPE)
statsd_client.timing_with_dates(
"notifications.tasks.send-email.queued-for",
sent_at,