##// END OF EJS Templates
Load only viewable post fields in thread
neko259 -
r1614:cc4b1dfa default
parent child Browse files
Show More
@@ -178,17 +178,22 b' class Thread(models.Model):'
178 reply_count - 1)
178 reply_count - 1)
179 return reply_count - last_replies_count - 1
179 return reply_count - last_replies_count - 1
180
180
181 def get_replies(self, view_fields_only=False) -> QuerySet:
181 # TODO Remove argument, it is not used
182 def get_replies(self, view_fields_only=True) -> QuerySet:
182 """
183 """
183 Gets sorted thread posts
184 Gets sorted thread posts
184 """
185 """
185
186 query = self.multi_replies.order_by('pub_time').prefetch_related(
186 query = self.multi_replies.order_by('pub_time').prefetch_related(
187 'thread', 'attachments')
187 'thread', 'attachments')
188 if view_fields_only:
189 query = query.defer('poster_ip')
190 return query
188 return query
191
189
190 def get_viewable_replies(self) -> QuerySet:
191 """
192 Gets replies with only fields that are used for viewing.
193 """
194 return self.get_replies().defer('poster_ip', 'text', 'last_edit_time',
195 'version')
196
192 def get_top_level_replies(self) -> QuerySet:
197 def get_top_level_replies(self) -> QuerySet:
193 return self.get_replies().exclude(refposts__threads__in=[self])
198 return self.get_replies().exclude(refposts__threads__in=[self])
194
199
@@ -36,7 +36,7 b''
36 {% endif %}
36 {% endif %}
37
37
38 <div class="thread">
38 <div class="thread">
39 {% for post in thread.get_replies %}
39 {% for post in thread.get_viewable_replies %}
40 {% post_view post reply_link=True %}
40 {% post_view post reply_link=True %}
41 {% endfor %}
41 {% endfor %}
42 </div>
42 </div>
General Comments 0
You need to be logged in to leave comments. Login now