Просмотр исходного кода

Merge pull request #255 from zrong/develop

Fix a bug about show a forum list
Peter Justin 8 лет назад
Родитель
Сommit
fbd46732e8
1 измененных файлов с 4 добавлено и 3 удалено
  1. 4 3
      flaskbb/forum/models.py

+ 4 - 3
flaskbb/forum/models.py

@@ -340,9 +340,10 @@ class Topic(db.Model, CRUDMixin):
         # If the topic is unread try to get the first unread post
         if topic_is_unread(self, topicsread, user, forumsread):
             # 
-            post = Post.query.filter(Post.topic_id == self.id).\
-                filter(Post.date_created > topicsread.last_read).\
-                order_by(Post.id.asc()).first()
+            query = Post.query.filter(Post.topic_id == self.id)
+            if topicsread is not None:
+                query = query.filter(Post.date_created > topicsread.last_read)
+            post = query.order_by(Post.id.asc()).first()
             if post is not None:
                 return post.url