Mercurial > public > sg101
view gpp/bio/signals.py @ 160:2eb3984ccb15
Implement #45, add a who's online feature for the forums. Created middleware that caches usernames and guest session ids in the cache. Added a tag that displays this info.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 22 Dec 2009 02:08:05 +0000 |
parents | 08cd19c1ee50 |
children | b4305e18d3af |
line wrap: on
line source
""" Signal handler(s) for the bio application. """ from django.db.models.signals import post_save from django.contrib.auth.models import User from bio.models import UserProfile def on_user_save(sender, **kwargs): """ This signal handler ensures that every User has a corresonding UserProfile. It is called after User instance is saved. It creates a UserProfile for the User if the created argument is True. """ created = kwargs['created'] if created: user = kwargs['instance'] profile = UserProfile() profile.user = user profile.save() post_save.connect(on_user_save, sender=User)