2020-06-10 04:57:56 +00:00
|
|
|
from flask_marshmallow.sqla import SQLAlchemyAutoSchema
|
2021-10-07 13:19:37 +00:00
|
|
|
from marshmallow import EXCLUDE, INCLUDE
|
2020-06-10 04:57:56 +00:00
|
|
|
from sqlalchemy import func
|
|
|
|
|
2021-10-07 13:19:37 +00:00
|
|
|
from crc import db, ma
|
2020-06-17 23:00:16 +00:00
|
|
|
from crc.models.study import StudyModel
|
2020-06-10 04:57:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EmailModel(db.Model):
|
|
|
|
__tablename__ = 'email'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
subject = db.Column(db.String)
|
|
|
|
sender = db.Column(db.String)
|
|
|
|
recipients = db.Column(db.String)
|
2021-10-07 13:19:37 +00:00
|
|
|
cc = db.Column(db.String, nullable=True)
|
|
|
|
bcc = db.Column(db.String, nullable=True)
|
2020-06-10 04:57:56 +00:00
|
|
|
content = db.Column(db.String)
|
|
|
|
content_html = db.Column(db.String)
|
2020-06-17 23:00:16 +00:00
|
|
|
study_id = db.Column(db.Integer, db.ForeignKey(StudyModel.id), nullable=True)
|
2021-10-07 13:19:37 +00:00
|
|
|
timestamp = db.Column(db.DateTime(timezone=True), default=func.now())
|
2021-10-12 17:42:11 +00:00
|
|
|
workflow_spec_id = db.Column(db.String, nullable=True)
|
2020-06-17 23:00:16 +00:00
|
|
|
study = db.relationship(StudyModel)
|
2021-10-07 13:19:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EmailModelSchema(ma.Schema):
|
2021-10-13 15:42:01 +00:00
|
|
|
|
2021-10-07 13:19:37 +00:00
|
|
|
class Meta:
|
|
|
|
model = EmailModel
|
2021-10-13 15:42:01 +00:00
|
|
|
fields = ["id", "subject", "sender", "recipients", "cc", "bcc", "content", "content_html",
|
|
|
|
"study_id", "timestamp", "workflow_spec_id"]
|