# HG changeset patch # User durandn # Date 1470401332 -7200 # Node ID 7a7f44c3b1243e81d12006b02678f71f5cc09818 # Parent 4a63b6ac7a961b7c8c859bcff414bcf24b59e34b *properly* fix sending two notifications to annotation author when creating comment diff -r 4a63b6ac7a96 -r 7a7f44c3b124 src/iconolab/signals/handlers.py --- a/src/iconolab/signals/handlers.py Fri Aug 05 13:06:38 2016 +0200 +++ b/src/iconolab/signals/handlers.py Fri Aug 05 14:48:52 2016 +0200 @@ -72,15 +72,15 @@ if sender == IconolabComment and instance.content_type.app_label == 'iconolab' and instance.content_type.model == 'annotation': comment_annotation = Annotation.objects.get(id=instance.object_pk) # Notifying new user comment - if instance.parent_id: + if instance.thread_id: notified_author = False - print("notifying! "+str(instance.parent_id)) if instance.level > 0: # We check parent_id as django comment xtd saves comments in two steps and only set the information we need in the second step parent_comment = IconolabComment.objects.get(id=instance.parent_id) - if parent_comment.user == comment_annotation.author: - notified_author = True - notify.send(instance.user, recipient=parent_comment.user, verb='a répondu à votre commentaire', action_object=instance, target=comment_annotation) - elif instance.user != comment_annotation.author and not notified_author: + if parent_comment.user != instance.user: + notify.send(instance.user, recipient=parent_comment.user, verb='a répondu à votre commentaire', action_object=instance, target=comment_annotation) + if parent_comment.user == comment_annotation.author: + notified_author = True + if instance.user != comment_annotation.author and not notified_author: notify.send(instance.user, recipient=comment_annotation.author, verb='a écrit un commentaire sur votre annotation', action_object=instance, target=comment_annotation)