-
-
-# WTF/unused
-# # was picture/picture_list.html list (without thumbs)
-# def picture_list(request, filter=None, get_filter=None, template_name='catalogue/picture_list.html',
-# cache_key=None, context=None):
-# """ generates a listing of all books, optionally filtered with a test function """
-#
-# if get_filter:
-# filt = get_filter()
-# pictures_by_author, orphans = Picture.picture_list(filt)
-# books_nav = OrderedDict()
-# for tag in pictures_by_author:
-# if pictures_by_author[tag]:
-# books_nav.setdefault(tag.sort_key[0], []).append(tag)
-#
-# return render_to_response(template_name, locals(), context_instance=RequestContext(request))
-
-
-def picture_list_thumb(request, filter=None, get_filter=None, template_name='picture/picture_list_thumb.html',
- cache_key=None, context=None):
- book_list = Picture.objects.all()
- if filter:
- book_list = book_list.filter(filter)
- if get_filter:
- book_list = book_list.filter(get_filter())
- book_list = book_list.order_by('sort_key_author')
- book_list = list(book_list)
- return render_to_response(template_name, locals(), context_instance=RequestContext(request))
+from wolnelektury.utils import ajax
+from catalogue.helpers import get_top_level_related_tags
+
+
+def picture_list_thumb(request):
+ pictures = Picture.objects.all()
+
+ if request.EXPERIMENTS['layout'].value:
+ related_tags = Tag.objects.usage_for_model(Picture, counts=True)
+ related_tags = sorted(related_tags, key=lambda t: -t.count)
+ suggestion_categories = Counter()
+ suggestions = []
+ for t in related_tags:
+ if suggestion_categories[t.category] < 3:
+ suggestion_categories[t.category] += 1
+ suggestions.append(t)
+ if sum(suggestion_categories.values()) == 10:
+ break
+ template_name = 'catalogue/2022/author_detail.html'
+ return render(request, template_name, {
+ 'object_list': pictures,
+ 'title': 'Galeria',
+ 'tags': [],
+ 'suggest': suggestions,
+ 'list_type': 'gallery',
+ })
+ else:
+ return render(request, template_name, {'picture_list': list(pictures)})