bgneal@1081: from django.db import models bgneal@1081: bgneal@1081: bgneal@1081: class ActiveEventManager(models.Manager): bgneal@1081: """Manager for all active events.""" bgneal@1081: def get_queryset(self): bgneal@1081: return super(ActiveEventManager, self).get_queryset().filter( bgneal@1081: is_active=True) bgneal@1081: bgneal@1081: bgneal@1081: class Event(models.Model): bgneal@1081: """Model for events we are counting down for.""" bgneal@1081: name = models.CharField(max_length=64) bgneal@1081: url = models.URLField(max_length=200) bgneal@1081: event_date = models.DateTimeField() bgneal@1081: is_active = models.BooleanField(db_index=True) bgneal@1081: bgneal@1081: objects = models.Manager() bgneal@1081: active_objects = ActiveEventManager() bgneal@1081: bgneal@1081: def __unicode__(self): bgneal@1081: return u"{} on {}".format( bgneal@1081: self.name, self.event_date.strftime('%m/%d/%Y')) bgneal@1081: bgneal@1081: class Meta: bgneal@1081: ordering = ['event_date']