mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
Choose postage when persisting a notification
This commit is contained in:
@@ -23,7 +23,8 @@ from app.models import (
|
||||
LETTER_TYPE,
|
||||
NOTIFICATION_CREATED,
|
||||
Notification,
|
||||
ScheduledNotification
|
||||
ScheduledNotification,
|
||||
CHOOSE_POSTAGE
|
||||
)
|
||||
from app.dao.notifications_dao import (
|
||||
dao_create_notification,
|
||||
@@ -31,6 +32,8 @@ from app.dao.notifications_dao import (
|
||||
dao_created_scheduled_notification
|
||||
)
|
||||
|
||||
from app.dao.templates_dao import dao_get_template_by_id
|
||||
|
||||
from app.v2.errors import BadRequestError
|
||||
from app.utils import (
|
||||
cache_key_for_service_template_counter,
|
||||
@@ -109,7 +112,11 @@ def persist_notification(
|
||||
elif notification_type == EMAIL_TYPE:
|
||||
notification.normalised_to = format_email_address(notification.to)
|
||||
elif notification_type == LETTER_TYPE:
|
||||
notification.postage = service.postage
|
||||
template = dao_get_template_by_id(template_id, template_version)
|
||||
if service.has_permission(CHOOSE_POSTAGE) and template.postage:
|
||||
notification.postage = template.postage
|
||||
else:
|
||||
notification.postage = service.postage
|
||||
|
||||
# if simulated create a Notification model to return but do not persist the Notification to the dB
|
||||
if not simulated:
|
||||
|
||||
Reference in New Issue
Block a user