Mercurial > public > sg101
comparison gpp/membermap/signals.py @ 46:0140ff687d49
Membermap bug: in the signal handler, if the user isn't on the map, just bail out.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 20 Jun 2009 03:23:54 +0000 |
parents | dbd703f7d63a |
children | 3a4bbf9c2cce |
comparison
equal
deleted
inserted
replaced
45:a5b4c5ce0658 | 46:0140ff687d49 |
---|---|
9 | 9 |
10 | 10 |
11 def on_profile_save(sender, **kwargs): | 11 def on_profile_save(sender, **kwargs): |
12 if 'instance' in kwargs: | 12 if 'instance' in kwargs: |
13 profile = kwargs['instance'] | 13 profile = kwargs['instance'] |
14 map_entry = MapEntry.objects.get(user=profile.user) | 14 try: |
15 map_entry = MapEntry.objects.get(user=profile.user) | |
16 except MapEntry.DoesNotExist: | |
17 # Not on the map, no harm, no foul | |
18 return | |
15 if map_entry is not None: | 19 if map_entry is not None: |
16 map_entry.save() | 20 map_entry.save() |
17 | 21 |
18 | 22 |
19 post_save.connect(on_profile_save, sender=UserProfile) | 23 post_save.connect(on_profile_save, sender=UserProfile) |
20 | |
21 # vim: ts=4 sw=4 |