from datetime import datetime from django.db import models from django.conf import settings class StoryManager(models.Manager): def published(self): return self.filter(sites=settings.SITE_ID, published=True, published_on__lte=datetime.now) def leads(self): return self.filter(published=True, lead=True, published_on__lte=datetime.now) def nonleads(self): return self.filter(published=True, lead=False, published_on__lte=datetime.now) def drafts(self): return self.filter(sites=settings.SITE_ID, published=False) class EditorialManager(models.Manager): def published(self): return self.filter(sites=settings.SITE_ID, published=True, published_on__lte=datetime.now) def drafts(self): return self.filter(sites=settings.SITE_ID, published=False) class EditionManager(models.Manager): def published(self): return self.filter(site=settings.SITE_ID, published=True, published_on__lte=datetime.now) class LeadStoryManager(models.Manager): def get_query_set(self): return super(LeadStoryManager, self).get_query_set().filter(lead=True, published=True) class PatriotEditionManager(models.Manager): def get_query_set(self): return super(PatriotEditionManager, self).get_query_set().filter(paper__name="Castine Patriot", published=True) class AdvantagesEditionManager(models.Manager): def get_query_set(self): return super(AdvantagesEditionManager, self).get_query_set().filter(paper__name="Island Ad-Vantages", published=True) class PacketEditionManager(models.Manager): def get_query_set(self): return super(PacketEditionManager, self).get_query_set().filter(paper__name="Weekly Packet", published=True) class CompassEditionManager(models.Manager): def get_query_set(self): return super(CompassEditionManager, self).get_query_set().filter(paper__name="Compass", published=True)