Mercurial > public > sg101
comparison gpp/membermap/signals.py @ 260:3a4bbf9c2cce
Fixing #107. Apparently some signal handlers were getting connected twice (double import?) and thus saving a forum post would cause 2 email notifications to go out to the post topic's subscribers. Use the dispatch_uid parameter in the connect call to work around this issue.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 22 Sep 2010 00:24:59 +0000 |
parents | 0140ff687d49 |
children | 6f3beff3ac63 |
comparison
equal
deleted
inserted
replaced
259:75ea1a8be7f2 | 260:3a4bbf9c2cce |
---|---|
7 from bio.models import UserProfile | 7 from bio.models import UserProfile |
8 from membermap.models import MapEntry | 8 from membermap.models import MapEntry |
9 | 9 |
10 | 10 |
11 def on_profile_save(sender, **kwargs): | 11 def on_profile_save(sender, **kwargs): |
12 import pdb; pdb.set_trace() | |
12 if 'instance' in kwargs: | 13 if 'instance' in kwargs: |
13 profile = kwargs['instance'] | 14 profile = kwargs['instance'] |
14 try: | 15 try: |
15 map_entry = MapEntry.objects.get(user=profile.user) | 16 map_entry = MapEntry.objects.get(user=profile.user) |
16 except MapEntry.DoesNotExist: | 17 except MapEntry.DoesNotExist: |
18 return | 19 return |
19 if map_entry is not None: | 20 if map_entry is not None: |
20 map_entry.save() | 21 map_entry.save() |
21 | 22 |
22 | 23 |
23 post_save.connect(on_profile_save, sender=UserProfile) | 24 post_save.connect(on_profile_save, |
25 sender=UserProfile, | |
26 dispatch_uid='membermap.signals') |