##// END OF EJS Templates
Don't include archived posts in the tag images
neko259 -
r1265:219062f3 default
parent child Browse files
Show More
@@ -91,8 +91,10 b' class Tag(models.Model, Viewable):'
91 def get_description(self):
91 def get_description(self):
92 return self.description
92 return self.description
93
93
94 def get_random_image_post(self):
94 def get_random_image_post(self, archived=False):
95 return boards.models.Post.objects.annotate(images_count=Count(
95 posts = boards.models.Post.objects.annotate(images_count=Count(
96 'images')).filter(images_count__gt=0, threads__tags__in=[self])\
96 'images')).filter(images_count__gt=0, threads__tags__in=[self])
97 .order_by('?').first()
97 if archived is not None:
98 posts = posts.filter(thread__archived=archived)
99 return posts.order_by('?').first()
98
100
General Comments 0
You need to be logged in to leave comments. Login now