Browse Source

Hopefully it is fixed now.

sh4nks 10 years ago
parent
commit
68ed072dbd
2 changed files with 12 additions and 4 deletions
  1. 3 1
      flaskbb/forum/models.py
  2. 9 3
      flaskbb/utils/helpers.py

+ 3 - 1
flaskbb/forum/models.py

@@ -507,6 +507,8 @@ class Topic(db.Model):
         # Set the last_updated time. Needed for the readstracker
         # Set the last_updated time. Needed for the readstracker
         self.last_updated = datetime.utcnow()
         self.last_updated = datetime.utcnow()
 
 
+        self.date_created = datetime.utcnow()
+
         # Insert and commit the topic
         # Insert and commit the topic
         db.session.add(self)
         db.session.add(self)
         db.session.commit()
         db.session.commit()
@@ -712,7 +714,7 @@ class Forum(db.Model):
             forumsread.save()
             forumsread.save()
             return True
             return True
 
 
-        # Nothing updated, because there are still more than 0 unread topics
+        # Nothing updated, because there are still more than 0 unread topicsread
         return False
         return False
 
 
     def save(self, moderators=None):
     def save(self, moderators=None):

+ 9 - 3
flaskbb/utils/helpers.py

@@ -157,10 +157,16 @@ def forum_is_unread(forum, forumsread, user):
         return forum.last_post.date_created > read_cutoff
         return forum.last_post.date_created > read_cutoff
 
 
     try:
     try:
-        # A user has never marked a forum as cleared
-        return forumsread.cleared < forum.last_post.date_created
+        # check if the forum has been cleared and if there is a new post
+        # since it have been cleared
+        if forum.last_post.date_created > forumsread.cleared:
+            if forum.last_post.date_created < forumsread.last_read:
+                return False
     except TypeError:
     except TypeError:
-        return forumsread.last_read < forum.last_post.date_created
+        pass
+
+    # else just check if the user has read the last post
+    return forum.last_post.date_created > forumsread.last_read
 
 
 
 
 def topic_is_unread(topic, topicsread, user, forumsread=None):
 def topic_is_unread(topic, topicsread, user, forumsread=None):