annotate countdown/models.py @ 1157:e4f2d6a4b401

Rework S3 connection logic for latest versions of Python 2.7. Had to make these changes for Ubuntu 16.04. Seems backward compatible with production.
author Brian Neal <bgneal@gmail.com>
date Thu, 19 Jan 2017 18:35:53 -0600
parents ecb8f07d937b
children
rev   line source
bgneal@1081 1 from django.db import models
bgneal@1081 2
bgneal@1081 3
bgneal@1081 4 class ActiveEventManager(models.Manager):
bgneal@1081 5 """Manager for all active events."""
bgneal@1081 6 def get_queryset(self):
bgneal@1081 7 return super(ActiveEventManager, self).get_queryset().filter(
bgneal@1081 8 is_active=True)
bgneal@1081 9
bgneal@1081 10
bgneal@1081 11 class Event(models.Model):
bgneal@1081 12 """Model for events we are counting down for."""
bgneal@1081 13 name = models.CharField(max_length=64)
bgneal@1081 14 url = models.URLField(max_length=200)
bgneal@1081 15 event_date = models.DateTimeField()
bgneal@1081 16 is_active = models.BooleanField(db_index=True)
bgneal@1081 17
bgneal@1081 18 objects = models.Manager()
bgneal@1081 19 active_objects = ActiveEventManager()
bgneal@1081 20
bgneal@1081 21 def __unicode__(self):
bgneal@1081 22 return u"{} on {}".format(
bgneal@1081 23 self.name, self.event_date.strftime('%m/%d/%Y'))
bgneal@1081 24
bgneal@1081 25 class Meta:
bgneal@1081 26 ordering = ['event_date']