# HG changeset patch # User ymh # Date 1530312654 -7200 # Node ID 303a7b5e8e5947c9dabc2a8e3b7e945419bdb05c # Parent f3bd5ed7d73857f7fdf903ea559a0b31d497fff3 * Correct division by zero when there is no tem in a collection * Remove unnecessary item and image prefetch on collection. * increment version diff -r f3bd5ed7d738 -r 303a7b5e8e59 src/iconolab/__init__.py --- a/src/iconolab/__init__.py Thu Jun 28 17:36:27 2018 +0200 +++ b/src/iconolab/__init__.py Sat Jun 30 00:50:54 2018 +0200 @@ -1,4 +1,4 @@ -VERSION = (0, 1, 3, "final", 0) +VERSION = (0, 1, 4, "final", 0) VERSION_STR = ".".join(map(lambda i: "%02d" % (i,), VERSION[:2])) diff -r f3bd5ed7d738 -r 303a7b5e8e59 src/iconolab/models.py --- a/src/iconolab/models.py Thu Jun 28 17:36:27 2018 +0200 +++ b/src/iconolab/models.py Sat Jun 30 00:50:54 2018 +0200 @@ -62,7 +62,7 @@ .values('image__item').distinct().count() total_items = self.items_count - return int(round((items_with_annotation * 100) / total_items)) + return int(round((items_with_annotation * 100) / total_items)) if total_items > 0 else 0 def __str__(self): return self.name diff -r f3bd5ed7d738 -r 303a7b5e8e59 src/iconolab/views/objects.py --- a/src/iconolab/views/objects.py Thu Jun 28 17:36:27 2018 +0200 +++ b/src/iconolab/views/objects.py Sat Jun 30 00:50:54 2018 +0200 @@ -102,8 +102,6 @@ if 'collection_name' in kwargs.keys(): try: objects_tuple += (Collection.objects.prefetch_related( - 'items', - 'items__images', Prefetch( 'folders', Folder.objects.annotate(items_nb=Count('item')).order_by('name') @@ -266,7 +264,7 @@ adjacent_pages_count = 2 # Paginated objects list - items_list = collection.items.order_by("metadatas__natural_key").prefetch_related('images', 'images__stats') + items_list = Item.objects.filter(collection=collection).prefetch_related('images', 'images__stats').select_related('collection').order_by('metadatas__natural_key') folder = request.GET.get('folder', None) @@ -289,7 +287,7 @@ items_pagination_args += "&folder=" + folder context["items_pagination_data"] = self.get_pagination_data( - items_list.all(), + items_list, items_page, items_per_page, adjacent_pages_count, @@ -449,7 +447,7 @@ }) image.stats.views_count += 1 image.stats.save() - return render(request, 'iconolab/detail_item.html', context); + return render(request, 'iconolab/detail_item.html', context) class ShowImageView(View, ContextMixin, IconolabObjectView): """