comparison gpp/mailer/models.py @ 180:aef00df91165

Implement #63, add a queued email facility.
author Brian Neal <bgneal@gmail.com>
date Sun, 21 Mar 2010 20:33:33 +0000
parents
children
comparison
equal deleted inserted replaced
179:70b2e307c866 180:aef00df91165
1 """Models for the mailer application."""
2 import datetime
3
4 from django.db import models
5
6
7 MAX_SUBJECT = 120
8
9 class Message(models.Model):
10 """The model to represent stored emails in the database."""
11 from_address = models.EmailField()
12 to_address = models.EmailField()
13 subject = models.CharField(max_length=MAX_SUBJECT)
14 body = models.TextField()
15 creation_date = models.DateTimeField()
16
17 class Meta:
18 ordering = ('creation_date', )
19
20 def __unicode__(self):
21 return u'From: %s, To: %s, Subj: %s' % (
22 self.from_address, self.to_address, self.subject)
23
24 def save(self, *args, **kwargs):
25 if self.id is None:
26 self.creation_date = datetime.datetime.now()
27 super(Message, self).save(*args, **kwargs)