diff --git a/boards/models/thread.py b/boards/models/thread.py --- a/boards/models/thread.py +++ b/boards/models/thread.py @@ -1,7 +1,7 @@ import logging from adjacent import Client -from django.db.models import Count, Sum +from django.db.models import Count, Sum, QuerySet from django.utils import timezone from django.db import models @@ -72,7 +72,7 @@ class Thread(models.Model): bumpable = models.BooleanField(default=True) max_posts = models.IntegerField(default=get_thread_max_posts) - def get_tags(self) -> list: + def get_tags(self) -> QuerySet: """ Gets a sorted tag list. """ @@ -118,7 +118,7 @@ class Thread(models.Model): return self.bumpable and not self.archived - def get_last_replies(self) -> list: + def get_last_replies(self) -> QuerySet: """ Gets several last replies, not including opening post """ @@ -145,7 +145,7 @@ class Thread(models.Model): reply_count - 1) return reply_count - last_replies_count - 1 - def get_replies(self, view_fields_only=False) -> list: + def get_replies(self, view_fields_only=False) -> QuerySet: """ Gets sorted thread posts """ @@ -156,10 +156,10 @@ class Thread(models.Model): query = query.defer('poster_ip') return query.all() - def get_top_level_replies(self): + def get_top_level_replies(self) -> QuerySet: return self.get_replies().exclude(refposts__threads__in=[self]) - def get_replies_with_images(self, view_fields_only=False) -> list: + def get_replies_with_images(self, view_fields_only=False) -> QuerySet: """ Gets replies that have at least one image attached """ @@ -167,14 +167,6 @@ class Thread(models.Model): return self.get_replies(view_fields_only).annotate(images_count=Count( 'images')).filter(images_count__gt=0) - # TODO Do we still need this? - def add_tag(self, tag: Tag): - """ - Connects thread to a tag and tag to a thread - """ - - self.tags.add(tag) - def get_opening_post(self, only_id=False) -> Post: """ Gets the first post of the thread