From: Harris Lapiroff Date: Mon, 28 Mar 2011 20:19:34 +0000 (-0400) Subject: Moved the EventQuerySet to its own class instead of nesting it in the Event model. X-Git-Tag: philo-0.9~16^2~6^2 X-Git-Url: http://git.ithinksw.org/philo.git/commitdiff_plain/9bb81b7a041bbe45235f53d37c864d49d51eff50?hp=96926ace045422f0f5f1f474a174ebbdc253a023 Moved the EventQuerySet to its own class instead of nesting it in the Event model. --- diff --git a/contrib/julian/models.py b/contrib/julian/models.py index 44b51f6..333bcb3 100644 --- a/contrib/julian/models.py +++ b/contrib/julian/models.py @@ -76,7 +76,17 @@ class TimedModel(models.Model): class EventManager(models.Manager): def get_query_set(self): - return self.model.QuerySet(self.model) + return EventQuerySet(self.model) + +class EventQuerySet(QuerySet): + def upcoming(self): + return self.filter(start_date__gte=datetime.date.today()) + def current(self): + return self.filter(start_date__lte=datetime.date.today(), end_date__gte=datetime.date.today()) + def single_day(self): + return self.filter(start_date__exact=models.F('end_date')) + def multiday(self): + return self.exclude(start_date__exact=models.F('end_date')) class Event(Entity, TimedModel): name = models.CharField(max_length=255) @@ -101,20 +111,6 @@ class Event(Entity, TimedModel): objects = EventManager() - class QuerySet(QuerySet): - - def upcoming(self): - return self.filter(start_date__gte=datetime.date.today()) - - def current(self): - return self.filter(start_date__lte=datetime.date.today(), end_date__gte=datetime.date.today()) - - def single_day(self): - return self.filter(start_date__exact=models.F('end_date')) - - def multiday(self): - return self.exclude(start_date__exact=models.F('end_date')) - def __unicode__(self): return self.name