##// END OF EJS Templates
Refactored type hints for thread model
neko259 -
r1186:6e932174 default
parent child Browse files
Show More
@@ -1,7 +1,7 b''
1 1 import logging
2 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 5 from django.utils import timezone
6 6 from django.db import models
7 7
@@ -72,7 +72,7 b' class Thread(models.Model):'
72 72 bumpable = models.BooleanField(default=True)
73 73 max_posts = models.IntegerField(default=get_thread_max_posts)
74 74
75 def get_tags(self) -> list:
75 def get_tags(self) -> QuerySet:
76 76 """
77 77 Gets a sorted tag list.
78 78 """
@@ -118,7 +118,7 b' class Thread(models.Model):'
118 118
119 119 return self.bumpable and not self.archived
120 120
121 def get_last_replies(self) -> list:
121 def get_last_replies(self) -> QuerySet:
122 122 """
123 123 Gets several last replies, not including opening post
124 124 """
@@ -145,7 +145,7 b' class Thread(models.Model):'
145 145 reply_count - 1)
146 146 return reply_count - last_replies_count - 1
147 147
148 def get_replies(self, view_fields_only=False) -> list:
148 def get_replies(self, view_fields_only=False) -> QuerySet:
149 149 """
150 150 Gets sorted thread posts
151 151 """
@@ -156,10 +156,10 b' class Thread(models.Model):'
156 156 query = query.defer('poster_ip')
157 157 return query.all()
158 158
159 def get_top_level_replies(self):
159 def get_top_level_replies(self) -> QuerySet:
160 160 return self.get_replies().exclude(refposts__threads__in=[self])
161 161
162 def get_replies_with_images(self, view_fields_only=False) -> list:
162 def get_replies_with_images(self, view_fields_only=False) -> QuerySet:
163 163 """
164 164 Gets replies that have at least one image attached
165 165 """
@@ -167,14 +167,6 b' class Thread(models.Model):'
167 167 return self.get_replies(view_fields_only).annotate(images_count=Count(
168 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 170 def get_opening_post(self, only_id=False) -> Post:
179 171 """
180 172 Gets the first post of the thread
General Comments 0
You need to be logged in to leave comments. Login now