annotate gpp/bulletins/models.py @ 11:cc8eb028def1

Update jquery-ui and theme version that is hosted on google. In preparation for having jquery on every page (?), make it so that the autocomplete plug is using the 'global' jquery, and not the one that came with it. It seems to work okay with jquery 1.3.2.
author Brian Neal <bgneal@gmail.com>
date Tue, 14 Apr 2009 02:35:35 +0000
parents dbd703f7d63a
children e249b5f9d180
rev   line source
gremmie@1 1 """Models for the bulletins app.
gremmie@1 2 Bulletins allow the sited admins to display and manage important notices for the website.
gremmie@1 3 """
gremmie@1 4
gremmie@1 5 import datetime
gremmie@1 6 from django.db import models
gremmie@1 7 from django.db.models import Q
gremmie@1 8
gremmie@1 9
gremmie@1 10 class BulletinManager(models.Manager):
gremmie@1 11 """Manager for the Bulletin model."""
gremmie@1 12
gremmie@1 13 def get_current(self):
gremmie@1 14 now = datetime.datetime.now()
gremmie@1 15 return self.filter(
gremmie@1 16 Q(is_enabled=True),
gremmie@1 17 Q(start_date__lte=now),
gremmie@1 18 Q(end_date__isnull=True) | Q(end_date__gte=now))
gremmie@1 19
gremmie@1 20
gremmie@1 21 class Bulletin(models.Model):
gremmie@1 22 """Model to represent site bulletins."""
gremmie@1 23 title = models.CharField(max_length=200)
gremmie@1 24 text = models.TextField()
gremmie@1 25 start_date = models.DateTimeField(db_index=True,
gremmie@1 26 help_text='Start date for when the bulletin will be active.',)
gremmie@1 27 end_date = models.DateTimeField(blank=True, null=True, db_index=True,
gremmie@1 28 help_text='End date for the bulletin. Leave blank to keep it open-ended.')
gremmie@1 29 is_enabled = models.BooleanField(default=True, db_index=True,
gremmie@1 30 help_text='Check to allow the bulletin to be viewed on the site.')
gremmie@1 31
gremmie@1 32 objects = BulletinManager()
gremmie@1 33
gremmie@1 34 def __unicode__(self):
gremmie@1 35 return self.title
gremmie@1 36
gremmie@1 37 class Meta:
gremmie@1 38 ordering = ('-start_date', )