Add columns to email model for reporting

Add Schema for email model
This commit is contained in:
mike cullerton 2021-10-07 09:19:37 -04:00
parent 448b7b2773
commit dab233a07a
1 changed files with 15 additions and 2 deletions

View File

@ -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