Show More
@@ -286,13 +286,12 b' class Post(models.Model, Viewable):' | |||||
286 | thread.save(update_fields=['last_edit_time']) |
|
286 | thread.save(update_fields=['last_edit_time']) | |
287 |
|
287 | |||
288 | @cached_result |
|
288 | @cached_result | |
289 |
def get_url(self |
|
289 | def get_url(self): | |
290 | """ |
|
290 | """ | |
291 | Gets full url to the post. |
|
291 | Gets full url to the post. | |
292 | """ |
|
292 | """ | |
293 |
|
293 | |||
294 | if not thread: |
|
294 | thread = self.get_thread() | |
295 | thread = self.get_thread() |
|
|||
296 |
|
295 | |||
297 | opening_id = thread.get_opening_post_id() |
|
296 | opening_id = thread.get_opening_post_id() | |
298 |
|
297 | |||
@@ -445,6 +444,11 b' class Post(models.Model, Viewable):' | |||||
445 | return self.text |
|
444 | return self.text | |
446 |
|
445 | |||
447 | def get_absolute_id(self) -> str: |
|
446 | def get_absolute_id(self) -> str: | |
|
447 | """ | |||
|
448 | If the post has many threads, shows its main thread OP id in the post | |||
|
449 | ID. | |||
|
450 | """ | |||
|
451 | ||||
448 | if self.get_threads().count() > 1: |
|
452 | if self.get_threads().count() > 1: | |
449 | return '{}/{}'.format(self.get_thread().get_opening_post_id(), self.id) |
|
453 | return '{}/{}'.format(self.get_thread().get_opening_post_id(), self.id) | |
450 | else: |
|
454 | else: |
@@ -121,7 +121,7 b' class Thread(models.Model):' | |||||
121 | """ |
|
121 | """ | |
122 |
|
122 | |||
123 | query = Post.objects.filter(threads__in=[self]) |
|
123 | query = Post.objects.filter(threads__in=[self]) | |
124 | query = query.order_by('pub_time').prefetch_related('images') |
|
124 | query = query.order_by('pub_time').prefetch_related('images', 'thread', 'threads') | |
125 | if view_fields_only: |
|
125 | if view_fields_only: | |
126 | query = query.defer('poster_user_agent') |
|
126 | query = query.defer('poster_user_agent') | |
127 | return query.all() |
|
127 | return query.all() |
@@ -13,7 +13,7 b'' | |||||
13 | {% endif %} |
|
13 | {% endif %} | |
14 |
|
14 | |||
15 | <div class="post-info"> |
|
15 | <div class="post-info"> | |
16 |
<a class="post_id" href="{ |
|
16 | <a class="post_id" href="{{ post.get_url }}" | |
17 | {% if not truncated and not thread.archived %} |
|
17 | {% if not truncated and not thread.archived %} | |
18 | onclick="javascript:addQuickReply('{{ post.id }}'); return false;" |
|
18 | onclick="javascript:addQuickReply('{{ post.id }}'); return false;" | |
19 | title="{% trans 'Quote' %}" {% endif %}>({{ post.get_absolute_id }})</a> |
|
19 | title="{% trans 'Quote' %}" {% endif %}>({{ post.get_absolute_id }})</a> |
@@ -25,18 +25,6 b' def post_url(*args, **kwargs):' | |||||
25 | return post.get_url() |
|
25 | return post.get_url() | |
26 |
|
26 | |||
27 |
|
27 | |||
28 | @register.simple_tag(name='post_object_url') |
|
|||
29 | def post_object_url(*args, **kwargs): |
|
|||
30 | post = args[0] |
|
|||
31 |
|
||||
32 | if 'thread' in kwargs: |
|
|||
33 | post_thread = kwargs['thread'] |
|
|||
34 | else: |
|
|||
35 | post_thread = None |
|
|||
36 |
|
||||
37 | return post.get_url(thread=post_thread) |
|
|||
38 |
|
||||
39 |
|
||||
40 | @register.simple_tag(name='image_actions') |
|
28 | @register.simple_tag(name='image_actions') | |
41 | def image_actions(*args, **kwargs): |
|
29 | def image_actions(*args, **kwargs): | |
42 | image_link = args[0] |
|
30 | image_link = args[0] |
General Comments 0
You need to be logged in to leave comments.
Login now