Update notification_history table on insert/update of notifications

triggered via calls in dao_create_notification and dao_update_notification - if you don't use those functions (eg update in bulk) you'll have to update the history table yourself!
This commit is contained in:
Leo Hemsted
2016-07-08 16:19:34 +01:00
parent 47ef63adbe
commit 722699a72a
5 changed files with 54 additions and 2 deletions

View File

@@ -409,6 +409,16 @@ class NotificationHistory(db.Model):
status = db.Column(NOTIFICATION_STATUS_TYPES_ENUM, nullable=False, default='created')
reference = db.Column(db.String, nullable=True, index=True)
@classmethod
def from_notification(cls, notification):
from app.schemas import notification_status_schema
return cls(notification_status_schema.dump(notification))
def update_from_notification(self, notification):
from app.schemas import notification_status_schema
new_notification_schema = cls(notification_status_schema.dump(notification))
INVITED_USER_STATUS_TYPES = ['pending', 'accepted', 'cancelled']