From dab233a07aa7dba7e276c5c61feb4636eba8ab08 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Thu, 7 Oct 2021 09:19:37 -0400 Subject: [PATCH] Add columns to email model for reporting Add Schema for email model --- crc/models/email.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/crc/models/email.py b/crc/models/email.py index dc8c6834..140efc7c 100644 --- a/crc/models/email.py +++ b/crc/models/email.py @@ -1,8 +1,8 @@ from flask_marshmallow.sqla import SQLAlchemyAutoSchema -from marshmallow import EXCLUDE +from marshmallow import EXCLUDE, INCLUDE from sqlalchemy import func -from crc import db +from crc import db, ma from crc.models.study import StudyModel @@ -12,7 +12,20 @@ class EmailModel(db.Model): subject = db.Column(db.String) sender = db.Column(db.String) recipients = db.Column(db.String) + cc = db.Column(db.String, nullable=True) + bcc = db.Column(db.String, nullable=True) content = db.Column(db.String) content_html = db.Column(db.String) study_id = db.Column(db.Integer, db.ForeignKey(StudyModel.id), nullable=True) + timestamp = db.Column(db.DateTime(timezone=True), default=func.now()) + workflow_id = db.Column(db.String, nullable=True) study = db.relationship(StudyModel) + + +class EmailModelSchema(ma.Schema): + # TODO: clean this us. Do we need load_instance and unknown? + class Meta: + model = EmailModel + load_instance = True + additional = ["id", "subject", "sender", "recipients", "timestamp"] + unknown = INCLUDE