Browse Source

Forums ignored the read_cutoff from the Topics

sh4nks 10 years ago
parent
commit
ef27babccb
1 changed files with 6 additions and 0 deletions
  1. 6 0
      flaskbb/forum/models.py

+ 6 - 0
flaskbb/forum/models.py

@@ -671,6 +671,11 @@ class Forum(db.Model):
         if not user.is_authenticated() or topicsread is None:
         if not user.is_authenticated() or topicsread is None:
             return False
             return False
 
 
+        read_cutoff = None
+        if flaskbb_config['TRACKER_LENGTH'] > 0:
+            read_cutoff = datetime.utcnow() - timedelta(
+                days=flaskbb_config['TRACKER_LENGTH'])
+
         # fetch the unread posts in the forum
         # fetch the unread posts in the forum
         unread_count = Topic.query.\
         unread_count = Topic.query.\
             outerjoin(TopicsRead,
             outerjoin(TopicsRead,
@@ -680,6 +685,7 @@ class Forum(db.Model):
                       db.and_(ForumsRead.forum_id == Topic.forum_id,
                       db.and_(ForumsRead.forum_id == Topic.forum_id,
                               ForumsRead.user_id == user.id)).\
                               ForumsRead.user_id == user.id)).\
             filter(Topic.forum_id == self.id,
             filter(Topic.forum_id == self.id,
+                   Topic.last_updated > read_cutoff,
                    db.or_(TopicsRead.last_read == None,
                    db.or_(TopicsRead.last_read == None,
                           TopicsRead.last_read < Topic.last_updated)).\
                           TopicsRead.last_read < Topic.last_updated)).\
             count()
             count()