annotate gpp/mailer/models.py @ 507:8631d32e6b16

Some users are still having problems with the pop-up login. I think they are actually getting 403s because of the CSRF protection. So I have modified the base template to always have a javascript variable called csrf_token available when they aren't logged in. The ajax_login.js script was then modified to send this value with the ajax post. Fingers crossed.
author Brian Neal <bgneal@gmail.com>
date Sun, 04 Dec 2011 03:05:21 +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)