fixed comment page calculation
authordurandn
Fri, 05 Aug 2016 12:14:33 +0200
changeset 101 eb856f9b518c
parent 100 8ec8aced3f68
child 102 4a63b6ac7a96
fixed comment page calculation
src/iconolab/models.py
--- a/src/iconolab/models.py	Fri Aug 05 10:01:50 2016 +0200
+++ b/src/iconolab/models.py	Fri Aug 05 12:14:33 2016 +0200
@@ -81,6 +81,7 @@
         self.tag_count = Tag.objects.filter(tagginginfo__revision__annotation__image = self.image).distinct().count()
         self.save()
 
+
 class Image(models.Model):
     image_guid = models.UUIDField(default=uuid.uuid4, editable=False)
     name = models.CharField(max_length=200)
@@ -129,6 +130,7 @@
         new_annotation.save()
         return new_annotation
 
+
 class AnnotationStats(models.Model):
     annotation = models.OneToOneField('Annotation', related_name='stats', blank=False, null=False)
     submitted_revisions_count = models.IntegerField(blank=True, null=True, default=1)
@@ -173,6 +175,7 @@
         
         self.save()
 
+
 class Annotation(models.Model):
     annotation_guid = models.UUIDField(default=uuid.uuid4, editable=False)
     image = models.ForeignKey('Image', related_name='annotations', on_delete=models.CASCADE)
@@ -366,6 +369,7 @@
                 except StopIteration:
                     pass
         return json.dumps(final_list) 
+
     
 class IconolabComment(XtdComment):
     revision = models.ForeignKey('AnnotationRevision', related_name='creation_comment', null=True, blank=True)
@@ -380,7 +384,8 @@
     def get_comment_page(self):
         return (self._default_manager.for_app_models("iconolab.annotation").filter(
             object_pk=self.object_pk,
-        ).filter(thread_id__gte=self.thread_id).filter(order__lte=self.order).count()) // settings.COMMENTS_PER_PAGE_DEFAULT + 1
+        ).filter(thread_id__gte=self.thread_id).filter(order__lte=self.order).count() +1) // settings.COMMENTS_PER_PAGE_DEFAULT + 1
+
     
 class MetaCategory(models.Model):
     NONE = 0 # Notifies nobody