Mercurial > public > sg101
annotate gpp/bio/signals.py @ 63:5899e308cdb3
Sigh, changed the donations data format because it seems to be different than the stand-alone IPN tester. The month name doesn't have a dot after it.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 27 Jun 2009 21:40:04 +0000 |
parents | 08cd19c1ee50 |
children | b4305e18d3af |
rev | line source |
---|---|
bgneal@44 | 1 """ |
bgneal@44 | 2 Signal handler(s) for the bio application. |
bgneal@44 | 3 """ |
bgneal@44 | 4 from django.db.models.signals import post_save |
bgneal@44 | 5 from django.contrib.auth.models import User |
bgneal@44 | 6 from bio.models import UserProfile |
bgneal@44 | 7 |
bgneal@44 | 8 def on_user_save(sender, **kwargs): |
bgneal@44 | 9 """ |
bgneal@44 | 10 This signal handler ensures that every User has a corresonding |
bgneal@44 | 11 UserProfile. It is called after User instance is saved. It creates |
bgneal@44 | 12 a UserProfile for the User if the created argument is True. |
bgneal@44 | 13 """ |
bgneal@44 | 14 created = kwargs['created'] |
bgneal@44 | 15 if created: |
bgneal@44 | 16 user = kwargs['instance'] |
bgneal@44 | 17 profile = UserProfile() |
bgneal@44 | 18 profile.user = user |
bgneal@44 | 19 profile.save() |
bgneal@44 | 20 |
bgneal@44 | 21 |
bgneal@44 | 22 post_save.connect(on_user_save, sender=User) |