Show More
@@ -1,7 +1,7 b'' | |||||
1 | import logging |
|
1 | import logging | |
2 | from adjacent import Client |
|
2 | from adjacent import Client | |
3 |
|
3 | |||
4 | from django.db.models import Count, Sum |
|
4 | from django.db.models import Count, Sum, QuerySet | |
5 | from django.utils import timezone |
|
5 | from django.utils import timezone | |
6 | from django.db import models |
|
6 | from django.db import models | |
7 |
|
7 | |||
@@ -72,7 +72,7 b' class Thread(models.Model):' | |||||
72 | bumpable = models.BooleanField(default=True) |
|
72 | bumpable = models.BooleanField(default=True) | |
73 | max_posts = models.IntegerField(default=get_thread_max_posts) |
|
73 | max_posts = models.IntegerField(default=get_thread_max_posts) | |
74 |
|
74 | |||
75 |
def get_tags(self) -> |
|
75 | def get_tags(self) -> QuerySet: | |
76 | """ |
|
76 | """ | |
77 | Gets a sorted tag list. |
|
77 | Gets a sorted tag list. | |
78 | """ |
|
78 | """ | |
@@ -118,7 +118,7 b' class Thread(models.Model):' | |||||
118 |
|
118 | |||
119 | return self.bumpable and not self.archived |
|
119 | return self.bumpable and not self.archived | |
120 |
|
120 | |||
121 |
def get_last_replies(self) -> |
|
121 | def get_last_replies(self) -> QuerySet: | |
122 | """ |
|
122 | """ | |
123 | Gets several last replies, not including opening post |
|
123 | Gets several last replies, not including opening post | |
124 | """ |
|
124 | """ | |
@@ -145,7 +145,7 b' class Thread(models.Model):' | |||||
145 | reply_count - 1) |
|
145 | reply_count - 1) | |
146 | return reply_count - last_replies_count - 1 |
|
146 | return reply_count - last_replies_count - 1 | |
147 |
|
147 | |||
148 |
def get_replies(self, view_fields_only=False) -> |
|
148 | def get_replies(self, view_fields_only=False) -> QuerySet: | |
149 | """ |
|
149 | """ | |
150 | Gets sorted thread posts |
|
150 | Gets sorted thread posts | |
151 | """ |
|
151 | """ | |
@@ -156,10 +156,10 b' class Thread(models.Model):' | |||||
156 | query = query.defer('poster_ip') |
|
156 | query = query.defer('poster_ip') | |
157 | return query.all() |
|
157 | return query.all() | |
158 |
|
158 | |||
159 | def get_top_level_replies(self): |
|
159 | def get_top_level_replies(self) -> QuerySet: | |
160 | return self.get_replies().exclude(refposts__threads__in=[self]) |
|
160 | return self.get_replies().exclude(refposts__threads__in=[self]) | |
161 |
|
161 | |||
162 |
def get_replies_with_images(self, view_fields_only=False) -> |
|
162 | def get_replies_with_images(self, view_fields_only=False) -> QuerySet: | |
163 | """ |
|
163 | """ | |
164 | Gets replies that have at least one image attached |
|
164 | Gets replies that have at least one image attached | |
165 | """ |
|
165 | """ | |
@@ -167,14 +167,6 b' class Thread(models.Model):' | |||||
167 | return self.get_replies(view_fields_only).annotate(images_count=Count( |
|
167 | return self.get_replies(view_fields_only).annotate(images_count=Count( | |
168 | 'images')).filter(images_count__gt=0) |
|
168 | 'images')).filter(images_count__gt=0) | |
169 |
|
169 | |||
170 | # TODO Do we still need this? |
|
|||
171 | def add_tag(self, tag: Tag): |
|
|||
172 | """ |
|
|||
173 | Connects thread to a tag and tag to a thread |
|
|||
174 | """ |
|
|||
175 |
|
||||
176 | self.tags.add(tag) |
|
|||
177 |
|
||||
178 | def get_opening_post(self, only_id=False) -> Post: |
|
170 | def get_opening_post(self, only_id=False) -> Post: | |
179 | """ |
|
171 | """ | |
180 | Gets the first post of the thread |
|
172 | Gets the first post of the thread |
General Comments 0
You need to be logged in to leave comments.
Login now