annotate gpp/mailer/models.py @ 434:ffdeb403ad21

For #211; update the URL in the private messages notification email. Messages no longer have a get_absolute_url() method. Just send people to the main messages index.
author Brian Neal <bgneal@gmail.com>
date Thu, 12 May 2011 02:56:13 +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)