19 lines
672 B
Python
19 lines
672 B
Python
|
from datetime import datetime
|
||
|
from app import db
|
||
|
from app.models.users import *
|
||
|
|
||
|
class Content(db.Model):
|
||
|
__tablename__ = 'content'
|
||
|
id = db.Column(db.Integer, primary_key=True)
|
||
|
type = db.Column(db.String(20))
|
||
|
__mapper_args__ = {
|
||
|
'polymorphic_identity':__tablename__,
|
||
|
'polymorphic_on': type
|
||
|
}
|
||
|
# Standalone properties
|
||
|
data = db.Column(db.Text(convert_unicode=True))
|
||
|
date_created = db.Column(db.DateTime, default=datetime.now)
|
||
|
date_modified = db.Column(db.DateTime, default=datetime.now)
|
||
|
# Relationships
|
||
|
author_id = db.Column(db.ForeignKey('user.id'))
|
||
|
author = db.relationship("User", back_populates="contents")
|