Added service and template relationship to notification model.

This makes it more consistent with other model classes with respect
to marhmallow serialisation/deserialisation.
This commit is contained in:
Adam Shimali
2016-02-09 12:48:27 +00:00
parent d24a356205
commit e5e049d735
4 changed files with 15 additions and 14 deletions

View File

@@ -6,8 +6,8 @@ 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)
update_dict.pop('service', None)
update_dict.pop('template', None)
Notification.query.filter_by(id=notification.id).update(update_dict)
else:
db.session.add(notification)

View File

@@ -203,7 +203,9 @@ class Notification(db.Model):
job_id = db.Column(UUID(as_uuid=True), db.ForeignKey('jobs.id'), index=True, unique=False, nullable=False)
job = db.relationship('Job', backref=db.backref('notifications', lazy='dynamic'))
service_id = db.Column(UUID(as_uuid=True), db.ForeignKey('services.id'), index=True, unique=False)
service = db.relationship('Service')
template_id = db.Column(db.BigInteger, db.ForeignKey('templates.id'), index=True, unique=False)
template = db.relationship('Template')
created_at = db.Column(
db.DateTime,
index=False,