# HG changeset patch # User neko259 # Date 2015-10-12 15:19:27 # Node ID 4837cb51f9f1a889adea2ca9ea9e640243a0691d # Parent 6850c2d22d0fe92692ed865732a13c22dcf00415 Show updated thread's link in favorite's new multipost diff --git a/boards/models/post/__init__.py b/boards/models/post/__init__.py --- a/boards/models/post/__init__.py +++ b/boards/models/post/__init__.py @@ -134,15 +134,24 @@ class Post(models.Model, Viewable): return self.opening - def get_absolute_url(self): - if self.url: - return self.url - else: - opening_id = self.get_thread().get_opening_post_id() - post_url = reverse('thread', kwargs={'post_id': opening_id}) + def get_absolute_url(self, thread=None): + url = None + + if thread is None: + thread = self.get_thread() + + # Url is cached only for the "main" thread. When getting url + # for other threads, do it manually. + if self.url: + url = self.url + + if url is None: + opening_id = thread.get_opening_post_id() + url = reverse('thread', kwargs={'post_id': opening_id}) if self.id != opening_id: - post_url += '#' + str(self.id) - return post_url + url += '#' + str(self.id) + + return url def get_thread(self): return self.thread @@ -330,7 +339,6 @@ class Post(models.Model, Viewable): """ Gets view of a reflink to the post. """ - result = '>>{}'.format(self.get_absolute_url(), self.id) if self.is_opening(): diff --git a/boards/views/api.py b/boards/views/api.py --- a/boards/views/api.py +++ b/boards/views/api.py @@ -273,7 +273,7 @@ def api_get_new_posts(request): new_post_count = thread.new_post_count fav_thread_dict['newest_post_link'] = thread.get_replies()\ .filter(id__gt=fav_threads[str(op.id)])\ - .first().get_absolute_url() + .first().get_absolute_url(thread=thread) else: new_post_count = 0 fav_thread_dict['new_post_count'] = new_post_count