Mercurial > public > sg101
comparison 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 |
comparison
equal
deleted
inserted
replaced
32:07da6967fc40 | 33:c018872385ea |
---|---|
1 """ | |
2 Models for the donations application. | |
3 """ | |
4 from django.db import models | |
5 from django.contrib import auth | |
6 | |
7 class Donation(models.Model): | |
8 """Model to represent a donation to the website.""" | |
9 | |
10 user = models.ForeignKey(auth.models.User, null=True, blank=True) | |
11 is_anonymous = models.BooleanField() | |
12 test_ipn = models.BooleanField(default=False, verbose_name="Test IPN") | |
13 txn_id = models.CharField(max_length=20, verbose_name="Txn ID") | |
14 txn_type = models.CharField(max_length=64) | |
15 first_name = models.CharField(max_length=64, blank=True) | |
16 last_name = models.CharField(max_length=64, blank=True) | |
17 payer_email = models.EmailField(max_length=127, blank=True) | |
18 payer_id = models.CharField(max_length=13, blank=True, verbose_name="Payer ID") | |
19 mc_fee = models.DecimalField(max_digits=8, decimal_places=2, verbose_name="Fee") | |
20 mc_gross = models.DecimalField(max_digits=8, decimal_places=2, verbose_name="Gross") | |
21 memo = models.TextField(blank=True) | |
22 payer_status = models.CharField(max_length=10, blank=True) | |
23 payment_date = models.DateTimeField() | |
24 | |
25 class Meta: | |
26 ordering = ('-payment_date', ) | |
27 | |
28 def __unicode__(self): | |
29 if self.user: | |
30 return u'%s from %s' % (self.mc_gross, self.user.username) | |
31 return u'%s from %s %s' % (self.mc_gross, self.first_name, self.last_name) | |
32 | |
33 def save(self, *args, **kwargs): | |
34 if self.user is None: | |
35 self.is_anonymous = True | |
36 super(Donation, self).save(*args, **kwargs) |