Show More
@@ -237,13 +237,15 b' class Post(models.Model):' | |||||
237 | poster_ip = models.GenericIPAddressField() |
|
237 | poster_ip = models.GenericIPAddressField() | |
238 | poster_user_agent = models.TextField() |
|
238 | poster_user_agent = models.TextField() | |
239 |
|
239 | |||
240 |
thread_new = models.ForeignKey('Thread', null=True, default=None |
|
240 | thread_new = models.ForeignKey('Thread', null=True, default=None, | |
|
241 | db_index=True) | |||
241 | last_edit_time = models.DateTimeField() |
|
242 | last_edit_time = models.DateTimeField() | |
242 | user = models.ForeignKey('User', null=True, default=None) |
|
243 | user = models.ForeignKey('User', null=True, default=None, db_index=True) | |
243 |
|
244 | |||
244 | referenced_posts = models.ManyToManyField('Post', symmetrical=False, |
|
245 | referenced_posts = models.ManyToManyField('Post', symmetrical=False, | |
245 | null=True, |
|
246 | null=True, | |
246 |
blank=True, related_name='rfp+' |
|
247 | blank=True, related_name='rfp+', | |
|
248 | db_index=True) | |||
247 |
|
249 | |||
248 | def __unicode__(self): |
|
250 | def __unicode__(self): | |
249 | return '#' + str(self.id) + ' ' + self.title + ' (' + \ |
|
251 | return '#' + str(self.id) + ' ' + self.title + ' (' + \ | |
@@ -413,8 +415,10 b' class Thread(models.Model):' | |||||
413 | reply_count_to_show = min(settings.LAST_REPLIES_COUNT, |
|
415 | reply_count_to_show = min(settings.LAST_REPLIES_COUNT, | |
414 | reply_count - 1) |
|
416 | reply_count - 1) | |
415 | last_replies = self.replies.order_by( |
|
417 | last_replies = self.replies.order_by( | |
416 |
'pub_time'). |
|
418 | 'pub_time').defer('image_hash', 'poster_user_agent', | |
417 | reply_count - reply_count_to_show:] |
|
419 | 'text_markup_type') \ | |
|
420 | .prefetch_related('referenced_posts')[ | |||
|
421 | reply_count - reply_count_to_show:] | |||
418 |
|
422 | |||
419 | return last_replies |
|
423 | return last_replies | |
420 |
|
424 | |||
@@ -435,9 +439,8 b' class Thread(models.Model):' | |||||
435 | query = self.replies.order_by('pub_time') |
|
439 | query = self.replies.order_by('pub_time') | |
436 | if view_fields_only: |
|
440 | if view_fields_only: | |
437 | query = query.defer( |
|
441 | query = query.defer( | |
438 |
'image_hash', 'poster_user_agent', 'text_markup_type' |
|
442 | 'image_hash', 'poster_user_agent', 'text_markup_type') | |
439 | 'last_edit_time') |
|
443 | return query.all().prefetch_related('referenced_posts') | |
440 | return query.all() |
|
|||
441 |
|
444 | |||
442 | def add_tag(self, tag): |
|
445 | def add_tag(self, tag): | |
443 | """ |
|
446 | """ |
@@ -71,7 +71,7 b'' | |||||
71 | {% if post.referenced_posts.exists %} |
|
71 | {% if post.referenced_posts.exists %} | |
72 | <div class="refmap"> |
|
72 | <div class="refmap"> | |
73 | {% trans "Replies" %}: |
|
73 | {% trans "Replies" %}: | |
74 |
{% for ref_post in post. |
|
74 | {% for ref_post in post.referenced_posts %} | |
75 | <a href="{% post_object_url ref_post thread=thread %}">>>{{ ref_post.id }}</a>{% if not forloop.last %},{% endif %} |
|
75 | <a href="{% post_object_url ref_post thread=thread %}">>>{{ ref_post.id }}</a>{% if not forloop.last %},{% endif %} | |
76 | {% endfor %} |
|
76 | {% endfor %} | |
77 | </div> |
|
77 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now