+ post_count = Column(Integer, nullable=False, default=0, index=True)
+
+ def specific_post(self, position):
+ """Returns post number `position` in this thread.
+
+ Positions are one-indexed. Negative indexes are allowed.
+ """
+
+ # Handle negative indexes
+ if position < 0:
+ position = self.post_count + position + 1
+
+ return self.posts.filter_by(position=position).one()
+
+ def can_create_post(self, user):
+ """Returns True ifff the named user can make a new post in this thread.
+ """
+ if not user.can('forum:create-post'):
+ return False
+
+ if self.forum.access_level == u'archive' and \
+ not user.can('forum:override-archive'):
+ return False
+
+ return True