annotate bulletins/models.py @ 645:99f7917702ca

Fix 081a88b3bfc8, javascript resize of forum images. Commit 081a88b3bfc8 broke those pages that loaded forums.js but did not load the imagesLoaded jQuery extension. Now we have arranged it so that only the forums topic view loads imagesLoaded and put the resizing javascript inline.
author Brian Neal <bgneal@gmail.com>
date Mon, 11 Mar 2013 15:30:25 -0500
parents ee87ea74d46b
children
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):
bgneal@54 11 """Manager for the Bulletin model."""
gremmie@1 12
bgneal@54 13 def get_current(self):
bgneal@54 14 now = datetime.datetime.now()
bgneal@54 15 return self.filter(
bgneal@54 16 Q(is_enabled=True),
bgneal@54 17 Q(start_date__lte=now),
bgneal@54 18 Q(end_date__isnull=True) | Q(end_date__gte=now))
gremmie@1 19
gremmie@1 20
gremmie@1 21 class Bulletin(models.Model):
bgneal@54 22 """Model to represent site bulletins."""
bgneal@54 23 title = models.CharField(max_length=200)
bgneal@54 24 text = models.TextField()
bgneal@54 25 start_date = models.DateTimeField(db_index=True,
bgneal@54 26 help_text='Start date for when the bulletin will be active.',)
bgneal@54 27 end_date = models.DateTimeField(blank=True, null=True, db_index=True,
bgneal@54 28 help_text='End date for the bulletin. Leave blank to keep it open-ended.')
bgneal@54 29 is_enabled = models.BooleanField(default=True, db_index=True,
bgneal@54 30 help_text='Check to allow the bulletin to be viewed on the site.')
gremmie@1 31
bgneal@54 32 objects = BulletinManager()
gremmie@1 33
bgneal@54 34 class Meta:
bgneal@54 35 ordering = ('-start_date', )
gremmie@1 36
bgneal@54 37 def __unicode__(self):
bgneal@54 38 return self.title