mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-19 14:08:47 -04: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:
@@ -15,7 +15,6 @@ from marshmallow import (
|
||||
)
|
||||
from marshmallow_sqlalchemy import field_for
|
||||
|
||||
from notifications_utils.field import Field
|
||||
from notifications_utils.recipients import (
|
||||
validate_email_address,
|
||||
InvalidEmailError,
|
||||
@@ -24,11 +23,10 @@ from notifications_utils.recipients import (
|
||||
validate_and_format_phone_number
|
||||
)
|
||||
|
||||
from notifications_utils.renderers import PassThrough
|
||||
|
||||
from app import ma
|
||||
from app import models
|
||||
from app.dao.permissions_dao import permission_dao
|
||||
from app.utils import get_template_instance
|
||||
|
||||
|
||||
def _validate_positive_number(value, msg="Not a positive integer"):
|
||||
@@ -390,19 +388,13 @@ class NotificationWithPersonalisationSchema(NotificationWithTemplateSchema):
|
||||
@post_dump
|
||||
def handle_template_merge(self, in_data):
|
||||
in_data['template'] = in_data.pop('template_history')
|
||||
from notifications_utils.template import Template
|
||||
template = Template(
|
||||
in_data['template'],
|
||||
in_data['personalisation'],
|
||||
renderer=PassThrough()
|
||||
)
|
||||
in_data['body'] = template.rendered
|
||||
template_type = in_data['template']['template_type']
|
||||
if template_type == 'email':
|
||||
in_data['subject'] = str(Field(template.subject, in_data['personalisation']))
|
||||
template = get_template_instance(in_data['template'], in_data['personalisation'])
|
||||
in_data['body'] = str(template)
|
||||
if in_data['template']['template_type'] == models.EMAIL_TYPE:
|
||||
in_data['subject'] = template.subject
|
||||
in_data['content_char_count'] = None
|
||||
else:
|
||||
in_data['content_char_count'] = len(in_data['body'])
|
||||
in_data['content_char_count'] = template.content_count
|
||||
|
||||
in_data.pop('personalisation', None)
|
||||
in_data['template'].pop('content', None)
|
||||
|
||||
Reference in New Issue
Block a user