# HG changeset patch # User neko259 # Date 2016-05-09 15:53:01 # Node ID 5966db37dc85e9252d9d63d3e483680418cf191c # Parent 344601de055ceba04fbec255a5db35f2a5ad8353 Do not connect already connected replies diff --git a/boards/models/post/__init__.py b/boards/models/post/__init__.py --- a/boards/models/post/__init__.py +++ b/boards/models/post/__init__.py @@ -347,10 +347,12 @@ def connect_replies(instance, **kwargs): try: referenced_post = Post.objects.get(id=post_id) - referenced_post.referenced_posts.add(instance) - referenced_post.last_edit_time = instance.pub_time - referenced_post.build_refmap() - referenced_post.save(update_fields=['refmap', 'last_edit_time']) + # Connect only to posts that are not connected to already + if not referenced_post.referenced_posts.filter(id=instance.id).exists(): + referenced_post.referenced_posts.add(instance) + referenced_post.last_edit_time = instance.pub_time + referenced_post.build_refmap() + referenced_post.save(update_fields=['refmap', 'last_edit_time']) except ObjectDoesNotExist: pass