You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
971 B

from django.db.models.query import QuerySet
from django.conf import settings
from hvad.models import TranslationManager
class SharedQueries(object):
"""Some queries that are identical for Gallery and Photo."""
def is_public(self):
"""Trivial filter - will probably become more complex as time goes by!"""
return self.filter(is_public=True)
def on_site(self):
"""Return objects linked to the current site only."""
return self.filter(sites__id=settings.SITE_ID)
class GalleryQuerySet(SharedQueries, TranslationManager):
pass
class PhotoQuerySet(SharedQueries, QuerySet):
pass
class PhotologueManager(TranslationManager):
def is_public(self):
"""Trivial filter - will probably become more complex as time goes by!"""
return self.filter(is_public=True)
def on_site(self):
"""Return objects linked to the current site only."""
return self.filter(sites__id=settings.SITE_ID)