Show More
@@ -134,15 +134,24 b' class Post(models.Model, Viewable):' | |||
|
134 | 134 | |
|
135 | 135 | return self.opening |
|
136 | 136 | |
|
137 | def get_absolute_url(self): | |
|
138 | if self.url: | |
|
139 | return self.url | |
|
140 |
|
|
|
141 |
|
|
|
142 | post_url = reverse('thread', kwargs={'post_id': opening_id}) | |
|
137 | def get_absolute_url(self, thread=None): | |
|
138 | url = None | |
|
139 | ||
|
140 | if thread is None: | |
|
141 | thread = self.get_thread() | |
|
142 | ||
|
143 | # Url is cached only for the "main" thread. When getting url | |
|
144 | # for other threads, do it manually. | |
|
145 | if self.url: | |
|
146 | url = self.url | |
|
147 | ||
|
148 | if url is None: | |
|
149 | opening_id = thread.get_opening_post_id() | |
|
150 | url = reverse('thread', kwargs={'post_id': opening_id}) | |
|
143 | 151 | if self.id != opening_id: |
|
144 |
|
|
|
145 | return post_url | |
|
152 | url += '#' + str(self.id) | |
|
153 | ||
|
154 | return url | |
|
146 | 155 | |
|
147 | 156 | def get_thread(self): |
|
148 | 157 | return self.thread |
@@ -330,7 +339,6 b' class Post(models.Model, Viewable):' | |||
|
330 | 339 | """ |
|
331 | 340 | Gets view of a reflink to the post. |
|
332 | 341 | """ |
|
333 | ||
|
334 | 342 | result = '<a href="{}">>>{}</a>'.format(self.get_absolute_url(), |
|
335 | 343 | self.id) |
|
336 | 344 | if self.is_opening(): |
@@ -273,7 +273,7 b' def api_get_new_posts(request):' | |||
|
273 | 273 | new_post_count = thread.new_post_count |
|
274 | 274 | fav_thread_dict['newest_post_link'] = thread.get_replies()\ |
|
275 | 275 | .filter(id__gt=fav_threads[str(op.id)])\ |
|
276 | .first().get_absolute_url() | |
|
276 | .first().get_absolute_url(thread=thread) | |
|
277 | 277 | else: |
|
278 | 278 | new_post_count = 0 |
|
279 | 279 | fav_thread_dict['new_post_count'] = new_post_count |
General Comments 0
You need to be logged in to leave comments.
Login now