diff --git a/boards/models.py b/boards/models.py --- a/boards/models.py +++ b/boards/models.py @@ -65,7 +65,7 @@ class PostManager(models.Manager): else: self._delete_old_threads() - self.connect_replies(post) + self.connect_replies(post) return post @@ -100,7 +100,7 @@ class PostManager(models.Manager): if page != ALL_PAGES: thread_count = threads.count() - if page < self.get_thread_page_count(tag=tag): + if page < self._get_page_count(thread_count): start_thread = page * settings.THREADS_PER_PAGE end_thread = min(start_thread + settings.THREADS_PER_PAGE, thread_count) @@ -131,8 +131,7 @@ class PostManager(models.Manager): else: threads = self.filter(thread=None) - return int(math.ceil(threads.count() / float( - settings.THREADS_PER_PAGE))) + return self._get_page_count(threads.count()) def _delete_old_threads(self): """ @@ -154,13 +153,16 @@ class PostManager(models.Manager): map(self.delete_post, old_threads) def connect_replies(self, post): - """Connect replies to a post to show them as a refmap""" + """Connect replies to a post to show them as a refmap""" - for reply_number in re.finditer(REGEX_REPLY, post.text.raw): - id = reply_number.group(1) - ref_post = self.filter(id=id) - if ref_post.count() > 0: - ref_post[0].referenced_posts.add(post) + for reply_number in re.finditer(REGEX_REPLY, post.text.raw): + id = reply_number.group(1) + ref_post = self.filter(id=id) + if ref_post.count() > 0: + ref_post[0].referenced_posts.add(post) + + def _get_page_count(self, thread_count): + return int(math.ceil(thread_count / float(settings.THREADS_PER_PAGE))) class TagManager(models.Manager): diff --git a/boards/templates/boards/posting_general.html b/boards/templates/boards/posting_general.html --- a/boards/templates/boards/posting_general.html +++ b/boards/templates/boards/posting_general.html @@ -14,6 +14,8 @@ {% block content %} + {% get_current_language as LANGUAGE_CODE %} + {% if tag %}