diff --git a/boards/models/__init__.py b/boards/models/__init__.py --- a/boards/models/__init__.py +++ b/boards/models/__init__.py @@ -1,4 +1,7 @@ -__author__ = 'neko259' +STATUS_ACTIVE = 'active' +STATUS_BUMPLIMIT = 'bumplimit' +STATUS_ARCHIVE = 'archived' + from boards.models.image import PostImage from boards.models.attachment import Attachment diff --git a/boards/models/image.py b/boards/models/image.py --- a/boards/models/image.py +++ b/boards/models/image.py @@ -4,8 +4,10 @@ from django.template.defaultfilters impo from boards import thumbs, utils import boards from boards.models.base import Viewable +from boards.models import STATUS_ARCHIVE from boards.utils import get_upload_filename + __author__ = 'neko259' @@ -28,7 +30,7 @@ class PostImageManager(models.Manager): return post_image def get_random_images(self, count, tags=None): - images = self + images = self.exclude(post_images__thread__status=STATUS_ARCHIVE) if tags is not None: images = images.filter(post_images__threads__tags__in=tags) return images.order_by('?')[:count] diff --git a/boards/models/thread.py b/boards/models/thread.py --- a/boards/models/thread.py +++ b/boards/models/thread.py @@ -5,9 +5,7 @@ from django.db.models import Count, Sum, from django.utils import timezone from django.db import models -STATUS_ACTIVE = 'active' -STATUS_BUMPLIMIT = 'bumplimit' -STATUS_ARCHIVE = 'archived' +from boards.models import STATUS_BUMPLIMIT, STATUS_ACTIVE, STATUS_ARCHIVE from boards import settings import boards