- Implemented persist_notification and send_notification_to_queue in the process_notifications module

- Not sure I want to create a new classmethod on Notifications to create from v2 request. Will take another look at that.
This commit is contained in:
Rebecca Law
2016-10-27 17:34:54 +01:00
parent c2eecdae36
commit 6e4bad135a
6 changed files with 158 additions and 24 deletions

View File

@@ -22,7 +22,7 @@ from app.authentication.utils import get_secret
from app import (
db,
encryption,
DATETIME_FORMAT)
DATETIME_FORMAT, create_uuid)
from app.history_meta import Versioned
@@ -562,6 +562,30 @@ class Notification(db.Model):
key_type=key_type
)
@classmethod
def from_v2_api_request(cls,
template_id,
template_version,
recipient,
service_id,
personalisation,
notification_type,
api_key_id,
key_type):
return cls(
id=create_uuid(),
template_id=template_id,
template_version=template_version,
to=recipient,
service_id=service_id,
status='created',
created_at=datetime.datetime.strftime(datetime.datetime.utcnow(), DATETIME_FORMAT),
personalisation=personalisation,
notification_type=notification_type,
api_key_id=api_key_id,
key_type=key_type
)
class NotificationHistory(db.Model):
__tablename__ = 'notification_history'