2019-08-20 17:34:00 +02:00
|
|
|
from app import db
|
|
|
|
|
|
|
|
|
|
|
|
class Forum(db.Model):
|
|
|
|
__tablename__ = 'forum'
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
|
|
|
|
|
|
# Standalone properties
|
|
|
|
name = db.Column(db.Unicode(64))
|
|
|
|
slug = db.Column(db.Unicode(64))
|
|
|
|
description = db.Column(db.UnicodeText)
|
|
|
|
|
|
|
|
# Relationships
|
|
|
|
parent_id = db.Column(db.Integer, db.ForeignKey('forum.id'), nullable=True)
|
2019-08-24 19:17:13 +02:00
|
|
|
parent = db.relationship('Forum', backref='sub_forums', remote_side=id,
|
|
|
|
lazy=True)
|
|
|
|
|
|
|
|
# Also [topics] which is provided by a backref from the Topic class
|
2019-08-20 17:34:00 +02:00
|
|
|
|
|
|
|
def __init__(self, name, description, priv_prefix):
|
|
|
|
self.name = name
|
|
|
|
self.description = description
|
|
|
|
self.priv_prefix = priv_prefix
|
|
|
|
|
|
|
|
def __repr__(self):
|
2019-08-21 16:50:23 +02:00
|
|
|
return f'<Forum: {self.name}>'
|