PCv5/app/models/comment.py

22 lines
667 B
Python

from app import db
from app.models.post import Post
class Comment(Post):
__tablename__ = 'comment'
__mapper_args__ = {'polymorphic_identity': __tablename__}
id = db.Column(db.Integer, db.ForeignKey('post.id'), primary_key=True)
# Standalone properties
text = db.Column(db.UnicodeText)
# Relationships
thread_id = db.Column(db.Integer, db.ForeignKey('thread.id'), nullable=False)
# attachement = db.relationship('Attachement', backref='comment')
def __init__(self, author, text, thread):
super.__init__(author, text)
if isinstance(thread, Thread):
thread = thread.id
self.thread_id = thread