Show More
@@ -15,6 +15,10 b' ARCHIVE_POPULARITY_MODIFIER = 0.5' | |||||
15 | class TagManager(models.Manager): |
|
15 | class TagManager(models.Manager): | |
16 |
|
16 | |||
17 | def get_not_empty_tags(self): |
|
17 | def get_not_empty_tags(self): | |
|
18 | """ | |||
|
19 | Gets tags that have non-archived threads. | |||
|
20 | """ | |||
|
21 | ||||
18 | tags = self.annotate(Count('threads')) \ |
|
22 | tags = self.annotate(Count('threads')) \ | |
19 | .filter(threads__count__gt=0).filter(threads__archived=False) \ |
|
23 | .filter(threads__count__gt=0).filter(threads__archived=False) \ | |
20 | .order_by('name') |
|
24 | .order_by('name') | |
@@ -42,13 +46,22 b' class Tag(models.Model):' | |||||
42 | return self.name |
|
46 | return self.name | |
43 |
|
47 | |||
44 | def is_empty(self): |
|
48 | def is_empty(self): | |
|
49 | """ | |||
|
50 | Checks if the tag has some threads. | |||
|
51 | """ | |||
|
52 | ||||
45 | return self.get_thread_count() == 0 |
|
53 | return self.get_thread_count() == 0 | |
46 |
|
54 | |||
47 | def get_thread_count(self): |
|
55 | def get_thread_count(self): | |
48 | return self.threads.count() |
|
56 | return self.threads.count() | |
49 |
|
57 | |||
50 | def get_popularity(self): |
|
58 | def get_popularity(self): | |
51 | all_post_count = Post.objects.all().count() |
|
59 | """ | |
|
60 | Gets tag's popularity value as a percentage of overall board post | |||
|
61 | count. | |||
|
62 | """ | |||
|
63 | ||||
|
64 | all_post_count = Post.objects.count() | |||
52 |
|
65 | |||
53 | tag_reply_count = 0.0 |
|
66 | tag_reply_count = 0.0 | |
54 |
|
67 | |||
@@ -61,6 +74,10 b' class Tag(models.Model):' | |||||
61 | return popularity |
|
74 | return popularity | |
62 |
|
75 | |||
63 | def get_linked_tags(self): |
|
76 | def get_linked_tags(self): | |
|
77 | """ | |||
|
78 | Gets tags linked to the current one. | |||
|
79 | """ | |||
|
80 | ||||
64 | tag_list = [] |
|
81 | tag_list = [] | |
65 | self.get_linked_tags_list(tag_list) |
|
82 | self.get_linked_tags_list(tag_list) | |
66 |
|
83 | |||
@@ -80,7 +97,9 b' class Tag(models.Model):' | |||||
80 | linked_tag.get_linked_tags_list(tag_list) |
|
97 | linked_tag.get_linked_tags_list(tag_list) | |
81 |
|
98 | |||
82 | def get_font_value(self): |
|
99 | def get_font_value(self): | |
83 | """Get tag font value to differ most popular tags in the list""" |
|
100 | """ | |
|
101 | Gets tag font value to differ most popular tags in the list | |||
|
102 | """ | |||
84 |
|
103 | |||
85 | popularity = self.get_popularity() |
|
104 | popularity = self.get_popularity() | |
86 |
|
105 | |||
@@ -91,6 +110,10 b' class Tag(models.Model):' | |||||
91 | return str(font_value) |
|
110 | return str(font_value) | |
92 |
|
111 | |||
93 | def get_post_count(self, archived=False): |
|
112 | def get_post_count(self, archived=False): | |
|
113 | """ | |||
|
114 | Gets posts count for the tag's threads. | |||
|
115 | """ | |||
|
116 | ||||
94 | posts_count = 0 |
|
117 | posts_count = 0 | |
95 |
|
118 | |||
96 | threads = self.threads.filter(archived=archived) |
|
119 | threads = self.threads.filter(archived=archived) |
General Comments 0
You need to be logged in to leave comments.
Login now