mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
[WIP] New model class and dao for notification. This will be used for
recording status and outcome of sending notifications.
This commit is contained in:
22
app/dao/notifications_dao.py
Normal file
22
app/dao/notifications_dao.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from app import db
|
||||
from app.models import Notification
|
||||
|
||||
|
||||
def save_notification(notification, update_dict={}):
|
||||
if update_dict:
|
||||
update_dict.pop('id', None)
|
||||
update_dict.pop('job', None)
|
||||
update_dict.pop('service_id', None)
|
||||
update_dict.pop('template_id', None)
|
||||
Notification.query.filter_by(id=notification.id).update(update_dict)
|
||||
else:
|
||||
db.session.add(notification)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def get_notification(job_id, notification_id):
|
||||
return Notification.query.filter_by(job_id=job_id, id=notification_id).one()
|
||||
|
||||
|
||||
def get_notifications_by_job(job_id):
|
||||
return Notification.query.filter_by(job_id=job_id).all()
|
||||
Reference in New Issue
Block a user