fixed problem with duplicate notifications for annotation author
authordurandn
Fri, 05 Aug 2016 13:06:38 +0200
changeset 102 4a63b6ac7a96
parent 101 eb856f9b518c
child 103 7a7f44c3b124
fixed problem with duplicate notifications for annotation author
src/iconolab/signals/handlers.py
src/iconolab/templates/iconolab/detail_annotation.html
--- a/src/iconolab/signals/handlers.py	Fri Aug 05 12:14:33 2016 +0200
+++ b/src/iconolab/signals/handlers.py	Fri Aug 05 13:06:38 2016 +0200
@@ -73,12 +73,16 @@
         comment_annotation = Annotation.objects.get(id=instance.object_pk)
         # Notifying new user comment
         if instance.parent_id:
-            if instance.user != comment_annotation.author:
-                notify.send(instance.user, recipient=comment_annotation.author, verb='a écrit un commentaire sur votre annotation', action_object=instance, target=comment_annotation)
+            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:
+                notify.send(instance.user, recipient=comment_annotation.author, verb='a écrit un commentaire sur votre annotation', action_object=instance, target=comment_annotation)
+            
 
 def notify_users_on_metacategory(sender, instance, created, **kwargs):
     from iconolab.models import MetaCategory, MetaCategoryInfo, Annotation
--- a/src/iconolab/templates/iconolab/detail_annotation.html	Fri Aug 05 12:14:33 2016 +0200
+++ b/src/iconolab/templates/iconolab/detail_annotation.html	Fri Aug 05 13:06:38 2016 +0200
@@ -266,8 +266,9 @@
         $(".reply-to-alert .reply-to-content").html(comment_content);
         $(".reply-to-alert .reply-to-subtext").html(comment_subtext);
         $(".reply-to-alert .reply-to-label-list").html(comment_labels);
-        $(".reply-to-container").slideDown();
-        $("#form-reply-to-label").get(0).scrollIntoView();
+        $(".reply-to-container").slideDown(complete=function(){
+			$("#id_comment").get(0).scrollIntoView();
+        });
         $("#reply-to-field").val(commentID);
     })
     $(".reply-to-cancel").click(function(event){