##// END OF EJS Templates
Don't show archived random images
neko259 -
r1416:ad1a3f8e default
parent child Browse files
Show More
@@ -1,4 +1,7 b''
1 __author__ = 'neko259'
1 STATUS_ACTIVE = 'active'
2 STATUS_BUMPLIMIT = 'bumplimit'
3 STATUS_ARCHIVE = 'archived'
4
2
5
3 from boards.models.image import PostImage
6 from boards.models.image import PostImage
4 from boards.models.attachment import Attachment
7 from boards.models.attachment import Attachment
@@ -4,8 +4,10 b' from django.template.defaultfilters impo'
4 from boards import thumbs, utils
4 from boards import thumbs, utils
5 import boards
5 import boards
6 from boards.models.base import Viewable
6 from boards.models.base import Viewable
7 from boards.models import STATUS_ARCHIVE
7 from boards.utils import get_upload_filename
8 from boards.utils import get_upload_filename
8
9
10
9 __author__ = 'neko259'
11 __author__ = 'neko259'
10
12
11
13
@@ -28,7 +30,7 b' class PostImageManager(models.Manager):'
28 return post_image
30 return post_image
29
31
30 def get_random_images(self, count, tags=None):
32 def get_random_images(self, count, tags=None):
31 images = self
33 images = self.exclude(post_images__thread__status=STATUS_ARCHIVE)
32 if tags is not None:
34 if tags is not None:
33 images = images.filter(post_images__threads__tags__in=tags)
35 images = images.filter(post_images__threads__tags__in=tags)
34 return images.order_by('?')[:count]
36 return images.order_by('?')[:count]
@@ -5,9 +5,7 b' from django.db.models import Count, Sum,'
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
8 STATUS_ACTIVE = 'active'
8 from boards.models import STATUS_BUMPLIMIT, STATUS_ACTIVE, STATUS_ARCHIVE
9 STATUS_BUMPLIMIT = 'bumplimit'
10 STATUS_ARCHIVE = 'archived'
11
9
12 from boards import settings
10 from boards import settings
13 import boards
11 import boards
General Comments 0
You need to be logged in to leave comments. Login now