*properly* fix sending two notifications to annotation author when creating comment
--- 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)