Browse Source

Fixed post deletion

sh4nks 11 years ago
parent
commit
d29b982f18
2 changed files with 3 additions and 4 deletions
  1. 1 0
      flaskbb/forum/models.py
  2. 2 4
      flaskbb/forum/views.py

+ 1 - 0
flaskbb/forum/models.py

@@ -226,6 +226,7 @@ class Post(db.Model):
         self.user.post_count -= 1
         self.topic.post_count -= 1
         self.topic.forum.post_count -= 1
+        db.session.commit()
 
         db.session.delete(self)
         db.session.commit()

+ 2 - 4
flaskbb/forum/views.py

@@ -362,14 +362,12 @@ def delete_post(post_id, slug=None):
         flash("You do not have the permissions to edit this post", "danger")
         return redirect(post.topic.url)
 
-    topic_id = post.topic_id
-
     post.delete()
 
     # If the post was the first post in the topic, redirect to the forums
     if post.first_post:
-        return redirect(post.topic.url)
-    return redirect(url_for('forum.view_topic', topic_id=topic_id))
+        return redirect(post.topic.forum.url)
+    return redirect(post.topic.url)
 
 
 @forum.route("/post/<int:post_id>/report", methods=["GET", "POST"])