Show More
@@ -140,6 +140,11 b' class Thread(models.Model):' | |||||
140 | .annotate(images_count=Count( |
|
140 | .annotate(images_count=Count( | |
141 | 'attachments')).aggregate(Sum('images_count'))['images_count__sum'] or 0 |
|
141 | 'attachments')).aggregate(Sum('images_count'))['images_count__sum'] or 0 | |
142 |
|
142 | |||
|
143 | @cached_result(key_method=_get_cache_key) | |||
|
144 | def get_attachment_count(self) -> int: | |||
|
145 | return self.get_replies().annotate(attachment_count=Count('attachments'))\ | |||
|
146 | .aggregate(Sum('attachment_count'))['attachment_count__sum'] or 0 | |||
|
147 | ||||
143 | def can_bump(self) -> bool: |
|
148 | def can_bump(self) -> bool: | |
144 | """ |
|
149 | """ | |
145 | Checks if the thread can be bumped by replying to it. |
|
150 | Checks if the thread can be bumped by replying to it. |
@@ -182,7 +182,7 b' function getReplyCount() {' | |||||
182 | } |
|
182 | } | |
183 |
|
183 | |||
184 | function getImageCount() { |
|
184 | function getImageCount() { | |
185 | return $('.thread').find('img').length |
|
185 | return $('.thread').find('.image').length | |
186 | } |
|
186 | } | |
187 |
|
187 | |||
188 | /** |
|
188 | /** |
@@ -153,7 +153,7 b'' | |||||
153 | <div class="metadata"> |
|
153 | <div class="metadata"> | |
154 | {% if need_open_link %} |
|
154 | {% if need_open_link %} | |
155 | ♥ {{ thread.get_reply_count }} |
|
155 | ♥ {{ thread.get_reply_count }} | |
156 |
❄ {{ thread.get_ |
|
156 | ❄ {{ thread.get_attachment_count }} | |
157 | <a href="{% url 'thread_gallery' post.id %}">G</a> |
|
157 | <a href="{% url 'thread_gallery' post.id %}">G</a> | |
158 | <a href="{% url 'thread_tree' post.id %}">T</a> |
|
158 | <a href="{% url 'thread_tree' post.id %}">T</a> | |
159 | {% endif %} |
|
159 | {% endif %} | |
@@ -163,4 +163,4 b'' | |||||
163 | </div> |
|
163 | </div> | |
164 | {% endif %} |
|
164 | {% endif %} | |
165 | </div> |
|
165 | </div> | |
166 | {% endautoescape %} No newline at end of file |
|
166 | {% endautoescape %} |
@@ -29,8 +29,8 b'' | |||||
29 | {% with replies_count=thread.get_reply_count%} |
|
29 | {% with replies_count=thread.get_reply_count%} | |
30 | ♥ <span id="reply-count">{{ thread.get_reply_count }}</span>{% if thread.has_post_limit %}/{{ thread.max_posts }}{% endif %} |
|
30 | ♥ <span id="reply-count">{{ thread.get_reply_count }}</span>{% if thread.has_post_limit %}/{{ thread.max_posts }}{% endif %} | |
31 | {% endwith %} |
|
31 | {% endwith %} | |
32 |
{% with |
|
32 | {% with attachment_count=thread.get_attachment_count%} | |
33 |
❄ <span id="image-count">{{ |
|
33 | ❄ <span id="image-count">{{ attachment_count }}</span> | |
34 | {% endwith %} |
|
34 | {% endwith %} | |
35 | {% trans 'Last update: ' %}<span id="last-update"><time datetime="{{ thread.last_edit_time|date:'c' }}">{{ thread.last_edit_time }}</time></span> |
|
35 | {% trans 'Last update: ' %}<span id="last-update"><time datetime="{{ thread.last_edit_time|date:'c' }}">{{ thread.last_edit_time }}</time></span> | |
36 | </span> |
|
36 | </span> |
General Comments 0
You need to be logged in to leave comments.
Login now