|
@@ -65,6 +65,9 @@ class Post(db.Model):
|
|
|
|
|
|
|
|
|
parent = topic.forum.parent
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
while parent is not None and not parent.is_category:
|
|
|
parent.last_post_id = self.id
|
|
|
parent.post_count += 1
|
|
@@ -138,9 +141,8 @@ class Topic(db.Model):
|
|
|
foreign_keys=[first_post_id])
|
|
|
|
|
|
|
|
|
- last_post_id = db.Column(db.Integer, db.ForeignKey("posts.id",
|
|
|
- ondelete="CASCADE",
|
|
|
- onupdate="CASCADE"))
|
|
|
+ last_post_id = db.Column(db.Integer, db.ForeignKey("posts.id"))
|
|
|
+
|
|
|
last_post = db.relationship("Post", backref="last_post", uselist=False,
|
|
|
foreign_keys=[last_post_id])
|
|
|
|
|
@@ -214,14 +216,13 @@ class Topic(db.Model):
|
|
|
|
|
|
try:
|
|
|
forum = self.forum
|
|
|
+
|
|
|
if self.id == topic[0].id:
|
|
|
|
|
|
while forum is not None and not forum.is_category:
|
|
|
forum.last_post_id = topic[1].last_post_id
|
|
|
forum.save()
|
|
|
forum = forum.parent
|
|
|
- else:
|
|
|
- forum.last_post_id = topic[1].last_post_id
|
|
|
|
|
|
except IndexError:
|
|
|
while forum is not None and not forum.is_category:
|
|
@@ -245,12 +246,8 @@ class Topic(db.Model):
|
|
|
db.session.commit()
|
|
|
|
|
|
while forum is not None and not forum.is_category:
|
|
|
- forum.topic_count = Topic.query.filter_by(
|
|
|
- forum_id=self.forum_id).count()
|
|
|
-
|
|
|
- forum.post_count = Post.query.filter(
|
|
|
- Post.topic_id == Topic.id,
|
|
|
- Topic.forum_id == self.forum_id).count()
|
|
|
+ forum.topic_count -= 1
|
|
|
+ forum.post_count -= 1
|
|
|
|
|
|
forum = forum.parent
|
|
|
|
|
@@ -328,6 +325,11 @@ class Forum(db.Model):
|
|
|
post_count = db.Column(db.Integer, default=0)
|
|
|
topic_count = db.Column(db.Integer, default=0)
|
|
|
|
|
|
+ moderators = db.Column(DenormalizedText)
|
|
|
+
|
|
|
+
|
|
|
+ parents = db.Column(DenormalizedText)
|
|
|
+
|
|
|
|
|
|
last_post_id = db.Column(db.Integer, db.ForeignKey("posts.id"))
|
|
|
last_post = db.relationship("Post", backref="last_post_forum",
|
|
@@ -340,8 +342,6 @@ class Forum(db.Model):
|
|
|
backref=db.backref("parent", remote_side=[id]),
|
|
|
cascade="all, delete-orphan")
|
|
|
|
|
|
- moderators = db.Column(DenormalizedText)
|
|
|
-
|
|
|
|
|
|
def __repr__(self):
|
|
|
"""
|