mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
Update utils to 12.0.0
Includes:
- [x] https://github.com/alphagov/notifications-utils/pull/94 (breaking
changes which are responsible for all the changes to the API in
this PR)
The test for `get_sms_fragment_count` has been removed because this
method is already tested in utils here:
ac20f7e99e/tests/test_base_template.py (L140-L159)
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
from datetime import datetime
|
||||
|
||||
from flask import current_app
|
||||
from notifications_utils.renderers import PassThrough
|
||||
from notifications_utils.template import Template
|
||||
|
||||
from app import redis_store
|
||||
from app.celery import provider_tasks
|
||||
@@ -11,14 +9,11 @@ from app.dao.notifications_dao import dao_create_notification, dao_delete_notifi
|
||||
from app.models import SMS_TYPE, Notification, KEY_TYPE_TEST, EMAIL_TYPE
|
||||
from app.notifications.validators import check_sms_content_char_count
|
||||
from app.v2.errors import BadRequestError, SendNotificationToQueueError
|
||||
from app.utils import get_template_instance
|
||||
|
||||
|
||||
def create_content_for_notification(template, personalisation):
|
||||
template_object = Template(
|
||||
template.__dict__,
|
||||
personalisation,
|
||||
renderer=PassThrough()
|
||||
)
|
||||
template_object = get_template_instance(template.__dict__, personalisation)
|
||||
check_placeholders(template_object)
|
||||
|
||||
if template_object.template_type == SMS_TYPE:
|
||||
|
||||
@@ -7,9 +7,6 @@ from flask import (
|
||||
current_app,
|
||||
json
|
||||
)
|
||||
from notifications_utils.field import Field
|
||||
from notifications_utils.renderers import PassThrough
|
||||
from notifications_utils.template import Template
|
||||
|
||||
from app import api_user, create_uuid, statsd_client
|
||||
from app.clients.email.aws_ses import get_aws_responses
|
||||
@@ -36,7 +33,7 @@ from app.schemas import (
|
||||
day_schema
|
||||
)
|
||||
from app.service.utils import service_allowed_to_send_to
|
||||
from app.utils import pagination_links
|
||||
from app.utils import pagination_links, get_template_instance
|
||||
|
||||
notifications = Blueprint('notifications', __name__)
|
||||
|
||||
@@ -255,13 +252,13 @@ def send_notification(notification_type):
|
||||
|
||||
def get_notification_return_data(notification_id, notification, template):
|
||||
output = {
|
||||
'body': template.rendered,
|
||||
'body': str(template),
|
||||
'template_version': notification['template_version'],
|
||||
'notification': {'id': notification_id}
|
||||
}
|
||||
|
||||
if template.template_type == 'email':
|
||||
output.update({'subject': str(Field(template.subject, template.values))})
|
||||
output.update({'subject': template.subject})
|
||||
|
||||
return output
|
||||
|
||||
@@ -288,11 +285,8 @@ def _service_allowed_to_send_to(notification, service):
|
||||
|
||||
|
||||
def create_template_object_for_notification(template, personalisation):
|
||||
template_object = Template(
|
||||
template.__dict__,
|
||||
personalisation,
|
||||
renderer=PassThrough()
|
||||
)
|
||||
template_object = get_template_instance(template.__dict__, personalisation)
|
||||
|
||||
if template_object.missing_data:
|
||||
message = 'Missing personalisation: {}'.format(", ".join(template_object.missing_data))
|
||||
errors = {'template': [message]}
|
||||
|
||||
Reference in New Issue
Block a user