view countdown/models.py @ 1166:130ac1e98cf4

More V3 forums tweaking. Adding attachments is working now. Adding a post via ajax is working. Still need to display attachments on posts.
author Brian Neal <bgneal@gmail.com>
date Sun, 20 Aug 2017 15:55:54 -0500
parents ecb8f07d937b
children
line wrap: on
line source
from django.db import models


class ActiveEventManager(models.Manager):
    """Manager for all active events."""
    def get_queryset(self):
        return super(ActiveEventManager, self).get_queryset().filter(
                is_active=True)


class Event(models.Model):
    """Model for events we are counting down for."""
    name = models.CharField(max_length=64)
    url = models.URLField(max_length=200)
    event_date = models.DateTimeField()
    is_active = models.BooleanField(db_index=True)

    objects = models.Manager()
    active_objects = ActiveEventManager()

    def __unicode__(self):
        return u"{} on {}".format(
            self.name, self.event_date.strftime('%m/%d/%Y'))

    class Meta:
        ordering = ['event_date']