diff options
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index b750ee613..b3956e2f1 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -4853,8 +4853,25 @@ class Author(FullSearch): "person": str(self.person) } + def merge(self, item, keep_old=False): + merge_model_objects(self, item, keep_old=keep_old) + + +def author_post_save(sender, **kwargs): + if not kwargs.get('instance'): + return + cached_label_changed(sender, **kwargs) + instance = kwargs.get('instance') + q = Author.objects.filter(person=instance.person, + author_type=instance.author_type) + if q.count() <= 1: + return + authors = list(q.all()) + for author in authors[1:]: + authors[0].merge(author) + -post_save.connect(cached_label_changed, sender=Author) +post_save.connect(author_post_save, sender=Author) class SourceType(HierarchicalType): |