La version 5 de Planète Casio. Regroupe le forum, les programmes, les tutoriel, les sprites et tous les autres outils développés par nos soins.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.1 KiB

from app import db
from import Post
from sqlalchemy.orm import backref
class Topic(Post):
__tablename__ = 'topic'
# ID of the underlying [Post] object
id = db.Column(db.Integer, db.ForeignKey(''), primary_key=True)
__mapper_args__ = {
'polymorphic_identity': __tablename__,
# Because there is an extra relation to Post (promotion), SQLAlchemy
# cannot guess which Post we inherit from; specify here.
'inherit_condition': id ==
# Post that the topic was promoted into. If this is not None, then the
# topic was published into a project and a redirection should be emitted
promotion_id = db.Column(db.Integer,db.ForeignKey(''),nullable=True)
promotion = db.relationship('Post', foreign_keys=promotion_id)
# Topic title
title = db.Column(db.Unicode(128))
# Parent forum
forum_id = db.Column(db.Integer, db.ForeignKey(''), nullable=False,
forum = db.relationship('Forum',
backref=backref('topics', lazy='dynamic'), foreign_keys=forum_id)
# Associated thread
thread_id = db.Column(db.Integer,db.ForeignKey(''),nullable=False)
thread = db.relationship('Thread', foreign_keys=thread_id,
# Number of views in the forum
views = db.Column(db.Integer)
def __init__(self, forum, author, title, thread):
Create a Topic.
forum -- parent forum or sub-forum (Forum)
author -- post author (User)
title -- topic title (unicode string)
thread -- discussion thread attached to the topic (Thread)
Post.__init__(self, author)
self.title = title
self.views = 0
self.thread = thread = forum
def delete(self):
"""Recursively delete topic and all associated contents."""
if self.promotion is None:
def __repr__(self):
return f'<Topic: #{}>'