annotate gpp/mailer/models.py @ 241:27bee3ac85e6

For #93: fix url scheme for downloads.
author Brian Neal <bgneal@gmail.com>
date Wed, 15 Sep 2010 01:01:40 +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)