mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-05 02:41:14 -05:00
Added boby and subject to the get_notifications schema
This commit is contained in:
@@ -608,6 +608,19 @@ class Notification(db.Model):
|
||||
|
||||
return _substitute_status_seq(status_or_statuses)
|
||||
|
||||
@property
|
||||
def content(self):
|
||||
from app.utils import get_template_instance
|
||||
template_object = get_template_instance(self.template.__dict__, self.personalisation)
|
||||
return str(template_object)
|
||||
|
||||
@property
|
||||
def subject(self):
|
||||
from app.utils import get_template_instance
|
||||
if self.notification_type == EMAIL_TYPE:
|
||||
template_object = get_template_instance(self.template.__dict__, self.personalisation)
|
||||
return template_object.subject
|
||||
|
||||
def serialize(self):
|
||||
|
||||
template_dict = {
|
||||
@@ -631,6 +644,8 @@ class Notification(db.Model):
|
||||
"type": self.notification_type,
|
||||
"status": self.status,
|
||||
"template": template_dict,
|
||||
"body": self.content,
|
||||
"subject": self.subject,
|
||||
"created_at": self.created_at.strftime(DATETIME_FORMAT),
|
||||
"sent_at": self.sent_at.strftime(DATETIME_FORMAT) if self.sent_at else None,
|
||||
"completed_at": self.completed_at()
|
||||
|
||||
@@ -7,7 +7,6 @@ from app.celery import provider_tasks
|
||||
from notifications_utils.clients import redis
|
||||
from app.dao.notifications_dao import dao_create_notification, dao_delete_notifications_and_history_by_id
|
||||
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
|
||||
|
||||
@@ -16,8 +15,6 @@ def create_content_for_notification(template, personalisation):
|
||||
template_object = get_template_instance(template.__dict__, personalisation)
|
||||
check_placeholders(template_object)
|
||||
|
||||
if template_object.template_type == SMS_TYPE:
|
||||
check_sms_content_char_count(template_object.content_count)
|
||||
return template_object
|
||||
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ get_notification_response = {
|
||||
"type": {"enum": ["sms", "letter", "email"]},
|
||||
"status": {"type": "string"},
|
||||
"template": template,
|
||||
"body": {"type": "string"},
|
||||
"subject": {"type": ["string", "null"]},
|
||||
"created_at": {"type": "string"},
|
||||
"sent_at": {"type": ["string", "null"]},
|
||||
"completed_at": {"type": ["string", "null"]}
|
||||
@@ -69,7 +71,7 @@ get_notification_response = {
|
||||
# technically, all keys are required since we always have all of them
|
||||
"id", "reference", "email_address", "phone_number",
|
||||
"line_1", "line_2", "line_3", "line_4", "line_5", "line_6", "postcode",
|
||||
"type", "status", "template", "created_at", "sent_at", "completed_at"
|
||||
"type", "status", "template", "body", "created_at", "sent_at", "completed_at"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user