annotate gpp/mailer/models.py @ 278:2a795fd602a4

Fix #130. Upgrade to Blueprints CSS 1.0. However I didn't keep their change to the even class. That seemed to be messed up. Hand edited it to the old version.
author Brian Neal <bgneal@gmail.com>
date Sun, 03 Oct 2010 00:26:42 +0000
parents aef00df91165
children
rev   line source
bgneal@180 1 """Models for the mailer application."""
bgneal@180 2 import datetime
bgneal@180 3
bgneal@180 4 from django.db import models
bgneal@180 5
bgneal@180 6
bgneal@180 7 MAX_SUBJECT = 120
bgneal@180 8
bgneal@180 9 class Message(models.Model):
bgneal@180 10 """The model to represent stored emails in the database."""
bgneal@180 11 from_address = models.EmailField()
bgneal@180 12 to_address = models.EmailField()
bgneal@180 13 subject = models.CharField(max_length=MAX_SUBJECT)
bgneal@180 14 body = models.TextField()
bgneal@180 15 creation_date = models.DateTimeField()
bgneal@180 16
bgneal@180 17 class Meta:
bgneal@180 18 ordering = ('creation_date', )
bgneal@180 19
bgneal@180 20 def __unicode__(self):
bgneal@180 21 return u'From: %s, To: %s, Subj: %s' % (
bgneal@180 22 self.from_address, self.to_address, self.subject)
bgneal@180 23
bgneal@180 24 def save(self, *args, **kwargs):
bgneal@180 25 if self.id is None:
bgneal@180 26 self.creation_date = datetime.datetime.now()
bgneal@180 27 super(Message, self).save(*args, **kwargs)