Commits

Stanislav Panasik committed 0447238

fixed several bugs in pybb with no-post topics and in permission check in views

Comments (0)

Files changed (3)

pybb/read_tracking.py

             tracking.last_read = datetime.now()
             tracking.save()
         # update topics if new post exists or cache entry is empty
-        if topic.last_post.pk > tracking.topics.get(str(topic.pk), 0):
-            tracking.topics[str(topic.pk)] = topic.last_post.pk
-            tracking.save()
+        if topic.last_post is not None:
+            if topic.last_post.pk > tracking.topics.get(str(topic.pk), 0):
+                tracking.topics[str(topic.pk)] = topic.last_post.pk
+                tracking.save()
     else:
         if topic.last_post is not None:
             # initialize topic tracking dict

pybb/templatetags/pybb_tags.py

                                                   topic.last_post.created):
             return False
 
-    if isinstance(track.topics, dict):
-        post_pk = track.topics.get(str(topic.pk), 0)
-        return topic.last_post.pk > post_pk
+        if isinstance(track.topics, dict):
+            post_pk = track.topics.get(str(topic.pk), 0)
+            return topic.last_post.pk > post_pk
 
     return True
 
     except Topic.DoesNotExist:
         raise Http404()
     
-    if (not request.user.is_superuser) and have_permissions(request, forum, 'deny-view-forum'):
+    if (not request.user.is_superuser) and have_permissions(request, topic.forum, 'deny-view-forum'):
         # user cannot view this topic because cannot view this forum
         return HttpResponseRedirect('/')