Browse Source

Return 404 if the topic doesn't exist.

sh4nks 9 years ago
parent
commit
5b29656dec
2 changed files with 2 additions and 2 deletions
  1. 1 1
      flaskbb/forum/models.py
  2. 1 1
      flaskbb/forum/views.py

+ 1 - 1
flaskbb/forum/models.py

@@ -360,7 +360,7 @@ class Topic(db.Model):
     @classmethod
     @classmethod
     @can_access_topic
     @can_access_topic
     def get_topic(cls, topic_id, user):
     def get_topic(cls, topic_id, user):
-        topic = Topic.query.filter_by(id=topic_id).first()
+        topic = Topic.query.filter_by(id=topic_id).first_or_404()
         return topic
         return topic
 
 
     def tracker_needs_update(self, forumsread, topicsread):
     def tracker_needs_update(self, forumsread, topicsread):

+ 1 - 1
flaskbb/forum/views.py

@@ -101,7 +101,7 @@ def view_topic(topic_id, slug=None):
     page = request.args.get('page', 1, type=int)
     page = request.args.get('page', 1, type=int)
 
 
     # Fetch some information about the topic
     # Fetch some information about the topic
-    topic = Topic.get_topic(topic_id=topic_id, user=current_user )
+    topic = Topic.get_topic(topic_id=topic_id, user=current_user)
 
 
     # Count the topic views
     # Count the topic views
     topic.views += 1
     topic.views += 1