annotate gpp/donations/models.py @ 33:c018872385ea

Slideshow for home page; Initial checkin for the donations application.
author Brian Neal <bgneal@gmail.com>
date Wed, 03 Jun 2009 00:59:17 +0000
parents
children d5d7e510ecd7
rev   line source
bgneal@33 1 """
bgneal@33 2 Models for the donations application.
bgneal@33 3 """
bgneal@33 4 from django.db import models
bgneal@33 5 from django.contrib import auth
bgneal@33 6
bgneal@33 7 class Donation(models.Model):
bgneal@33 8 """Model to represent a donation to the website."""
bgneal@33 9
bgneal@33 10 user = models.ForeignKey(auth.models.User, null=True, blank=True)
bgneal@33 11 is_anonymous = models.BooleanField()
bgneal@33 12 test_ipn = models.BooleanField(default=False, verbose_name="Test IPN")
bgneal@33 13 txn_id = models.CharField(max_length=20, verbose_name="Txn ID")
bgneal@33 14 txn_type = models.CharField(max_length=64)
bgneal@33 15 first_name = models.CharField(max_length=64, blank=True)
bgneal@33 16 last_name = models.CharField(max_length=64, blank=True)
bgneal@33 17 payer_email = models.EmailField(max_length=127, blank=True)
bgneal@33 18 payer_id = models.CharField(max_length=13, blank=True, verbose_name="Payer ID")
bgneal@33 19 mc_fee = models.DecimalField(max_digits=8, decimal_places=2, verbose_name="Fee")
bgneal@33 20 mc_gross = models.DecimalField(max_digits=8, decimal_places=2, verbose_name="Gross")
bgneal@33 21 memo = models.TextField(blank=True)
bgneal@33 22 payer_status = models.CharField(max_length=10, blank=True)
bgneal@33 23 payment_date = models.DateTimeField()
bgneal@33 24
bgneal@33 25 class Meta:
bgneal@33 26 ordering = ('-payment_date', )
bgneal@33 27
bgneal@33 28 def __unicode__(self):
bgneal@33 29 if self.user:
bgneal@33 30 return u'%s from %s' % (self.mc_gross, self.user.username)
bgneal@33 31 return u'%s from %s %s' % (self.mc_gross, self.first_name, self.last_name)
bgneal@33 32
bgneal@33 33 def save(self, *args, **kwargs):
bgneal@33 34 if self.user is None:
bgneal@33 35 self.is_anonymous = True
bgneal@33 36 super(Donation, self).save(*args, **kwargs)