Add sms sender to service to be used in sms templates

in place of default numeric short code.

If not present default short code is used.
This commit is contained in:
Adam Shimali
2016-07-01 14:06:32 +01:00
parent 5e0033e36d
commit c29dd23702
11 changed files with 181 additions and 27 deletions

View File

@@ -1,27 +1,24 @@
import json
from datetime import datetime
from monotonic import monotonic
from flask import current_app
from app import notify_celery, statsd_client, encryption, clients
from app import notify_celery, statsd_client, clients
from app.clients.sms import SmsClientException
from app.dao.notifications_dao import (
update_provider_stats,
get_notification_by_id,
dao_update_notification, update_notification_status_by_id)
dao_update_notification,
update_notification_status_by_id
)
from app.dao.provider_details_dao import get_provider_details_by_notification_type
from app.dao.services_dao import dao_fetch_service_by_id
from app.dao.templates_dao import dao_get_template_by_id
from app.celery.research_mode_tasks import send_sms_response
from notifications_utils.recipients import (
validate_and_format_phone_number
)
from app.dao.templates_dao import dao_get_template_by_id
from notifications_utils.template import (
Template,
unlink_govuk_escaped
)
from notifications_utils.recipients import validate_and_format_phone_number
from notifications_utils.template import Template
from app.models import SMS_TYPE
@@ -57,12 +54,12 @@ def send_sms_to_provider(self, service_id, notification_id, encrypted_notificati
provider = provider_to_use(SMS_TYPE, notification_id)
notification = get_notification_by_id(notification_id)
if notification.status == 'created':
template_model = dao_get_template_by_id(notification.template_id, notification.template_version)
template = Template(
dao_get_template_by_id(notification.template_id, notification.template_version).__dict__,
template_model.__dict__,
values={} if not notification.personalisation else notification.personalisation,
prefix=service.name
)
try:
if service.research_mode:
send_sms_response.apply_async(
@@ -72,7 +69,8 @@ def send_sms_to_provider(self, service_id, notification_id, encrypted_notificati
provider.send_sms(
to=validate_and_format_phone_number(notification.to),
content=template.replaced,
reference=str(notification_id)
reference=str(notification_id),
sender=service.sms_sender
)
update_provider_stats(