Mercurial > public > sg101
annotate countdown/models.py @ 1146:439eb97a6ca8
Add friends logos to V3 base template.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 15 Nov 2016 19:44:29 -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'] |