2019-08-20 17:34:00 +02:00
|
|
|
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):
|
2019-08-21 16:50:23 +02:00
|
|
|
Post.__init__(author, text)
|
2019-08-20 17:34:00 +02:00
|
|
|
if isinstance(thread, Thread):
|
|
|
|
thread = thread.id
|
|
|
|
self.thread_id = thread
|