diff --git a/boards/models/post.py b/boards/models/post.py --- a/boards/models/post.py +++ b/boards/models/post.py @@ -298,7 +298,7 @@ class Post(models.Model): thread.last_edit_time = edit_time thread.save() - def get_url(self): + def get_url(self, thread=None): """ Gets full url to the post. """ @@ -307,7 +307,10 @@ class Post(models.Model): link = cache.get(cache_key) if not link: - opening_id = self.get_thread().get_opening_post_id() + if not thread: + thread = self.get_thread() + + opening_id = thread.get_opening_post_id() if self.id != opening_id: link = reverse('thread', kwargs={ diff --git a/boards/templates/boards/post.html b/boards/templates/boards/post.html --- a/boards/templates/boards/post.html +++ b/boards/templates/boards/post.html @@ -31,7 +31,7 @@
{{ post.title }} - + ({{ post.id }}) [{{ post.pub_time }}] {% if thread.archived %} @@ -73,8 +73,7 @@
{% trans "Replies" %}: {% for ref_post in refposts %} - >>{{ ref_post.id }}{% if not forloop.last %},{% endif %} + >>{{ ref_post.id }}{% if not forloop.last %},{% endif %} {% endfor %}
{% endif %} diff --git a/boards/templates/boards/thread.html b/boards/templates/boards/thread.html --- a/boards/templates/boards/thread.html +++ b/boards/templates/boards/thread.html @@ -33,16 +33,14 @@
{% with can_bump=thread.can_bump %} - {% with opening_post_id=thread.get_opening_post.id %} {% for post in thread.get_replies %} {% if forloop.first %} - {% post_view post moderator=moderator is_opening=True thread=thread can_bump=can_bump opening_post_id=opening_post_id %} + {% post_view post moderator=moderator is_opening=True thread=thread can_bump=can_bump opening_post_id=opening_post.id %} {% else %} - {% post_view post moderator=moderator is_opening=False thread=thread can_bump=can_bump opening_post_id=opening_post_id %} + {% post_view post moderator=moderator is_opening=False thread=thread can_bump=can_bump opening_post_id=opening_post.id %} {% endif %} {% endfor %} {% endwith %} - {% endwith %}
{% if not thread.archived %} diff --git a/boards/templatetags/board.py b/boards/templatetags/board.py --- a/boards/templatetags/board.py +++ b/boards/templatetags/board.py @@ -30,7 +30,12 @@ def post_url(*args, **kwargs): def post_object_url(*args, **kwargs): post = args[0] - return post.get_url() + if 'thread' in kwargs: + post_thread = kwargs['thread'] + else: + post_thread = None + + return post.get_url(thread=post_thread) @register.simple_tag(name='image_actions') diff --git a/boards/views/thread.py b/boards/views/thread.py --- a/boards/views/thread.py +++ b/boards/views/thread.py @@ -45,7 +45,7 @@ class ThreadView(BaseBoardView, PostMixi float(context['posts_left']) / neboard.settings.MAX_POSTS_PER_THREAD * 100) - context['opening_post'] = thread_to_show.get_opening_post() + context['opening_post'] = opening_post document = 'boards/thread.html' elif MODE_GALLERY == mode: