##// END OF EJS Templates
Add up to 5 random related tags instead of all related list
neko259 -
r1270:ba7bc8db default
parent child Browse files
Show More
@@ -10,6 +10,9 b' import boards'
10 __author__ = 'neko259'
10 __author__ = 'neko259'
11
11
12
12
13 RELATED_TAGS_COUNT = 5
14
15
13 class TagManager(models.Manager):
16 class TagManager(models.Manager):
14
17
15 def get_not_empty_tags(self):
18 def get_not_empty_tags(self):
@@ -102,5 +105,5 b' class Tag(models.Model, Viewable):'
102 return self.name and self.name[0] or ''
105 return self.name and self.name[0] or ''
103
106
104 def get_related_tags(self):
107 def get_related_tags(self):
105 return Tag.objects.filter(thread_tags__in=self.get_threads()).exclude(
108 return set(Tag.objects.filter(thread_tags__in=self.get_threads()).exclude(
106 id=self.id).distinct()
109 id=self.id).order_by('?')[:RELATED_TAGS_COUNT])
@@ -51,7 +51,7 b' class TagView(AllThreadsView, Dispatcher'
51 params[PARAM_IS_HIDDEN] = hidden_tag_names is not None and tag.name in hidden_tag_names
51 params[PARAM_IS_HIDDEN] = hidden_tag_names is not None and tag.name in hidden_tag_names
52
52
53 params[PARAM_RANDOM_IMAGE_POST] = tag.get_random_image_post()
53 params[PARAM_RANDOM_IMAGE_POST] = tag.get_random_image_post()
54 params[PARAM_RELATED_TAGS] = tag.get_related_tags().all()
54 params[PARAM_RELATED_TAGS] = tag.get_related_tags()
55
55
56 return params
56 return params
57
57
General Comments 0
You need to be logged in to leave comments. Login now