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