# HG changeset patch # User durandn # Date 1469801828 -7200 # Node ID 23679a6def7759516d4fd5f056725f8418c4b013 # Parent 7f27a0071b87aa6e1152664239a605e26424ee59 fixed error on stats (comments count not updating correctly for images) diff -r 7f27a0071b87 -r 23679a6def77 src/iconolab/models.py --- a/src/iconolab/models.py Tue Aug 02 16:19:31 2016 +0200 +++ b/src/iconolab/models.py Fri Jul 29 16:17:08 2016 +0200 @@ -59,7 +59,6 @@ def set_tags_stats(self): self.tag_count = Tag.objects.filter(tagginginfo__revision__annotation__image = self.image).distinct().count() - self.save() def update_stats(self): self.annotations_count = 0 @@ -93,14 +92,6 @@ def __str__(self): return self.name -# # Folders -# class Folder(models.Model): -# label = models.CharField(max_length=255) -# owner = models.ForeignKey(User) -# images = models.ManyToManyField(Image) -# -# def __str__(self): -# return label class AnnotationManager(models.Manager): @@ -156,7 +147,6 @@ def set_tags_stats(self): self.tag_count = Tag.objects.filter(tagginginfo__revision__annotation = self.annotation).distinct().count() - self.save() def update_stats(self): # views_count - Can't do much about views count @@ -330,7 +320,8 @@ "tag_label": tagging_info.tag.label, "tag_link": tagging_info.tag.link, "accuracy": tagging_info.accuracy, - "relevancy": tagging_info.relevancy + "relevancy": tagging_info.relevancy, + "is_internal": tagging_info.tag.is_internal() }) else: tag_link = tagging_info.tag.link @@ -346,7 +337,8 @@ "tag_label": tag_label, "tag_link": tag_link, "accuracy": tagging_info.accuracy, - "relevancy": tagging_info.relevancy + "relevancy": tagging_info.relevancy, + "is_internal": tagging_info.tag.is_internal() }) except StopIteration: pass diff -r 7f27a0071b87 -r 23679a6def77 src/iconolab/signals/handlers.py --- a/src/iconolab/signals/handlers.py Tue Aug 02 16:19:31 2016 +0200 +++ b/src/iconolab/signals/handlers.py Fri Jul 29 16:17:08 2016 +0200 @@ -27,12 +27,13 @@ def increment_stats_on_new_comments(sender, instance, created, **kwargs): if created: - print("COMMENT WAS CREATED") model = apps.get_model(instance.content_type.app_label,instance.content_type.model) object_pk = instance.object_pk annotation = model._default_manager.get(pk=object_pk) annotation.stats.comments_count +=1 annotation.stats.save() + annotation.image.stats.comments_count +=1 + annotation.image.stats.save() def increment_accepted_revisions(sender, instance, **kwargs):