X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/4727eb31e50fa1571c83c4be5e228534b07574a7..7e1eb02f59f06e2d40e85be4dda05f7a222fe593:/src/search/views.py?ds=sidebyside diff --git a/src/search/views.py b/src/search/views.py index f7953c315..e439c4128 100644 --- a/src/search/views.py +++ b/src/search/views.py @@ -1,5 +1,5 @@ -# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # from django.conf import settings from django.shortcuts import render @@ -9,7 +9,6 @@ from sorl.thumbnail import get_thumbnail import catalogue.models import infopages.models -import picture.models from .forms import SearchFilters import re import json @@ -48,7 +47,7 @@ def hint(request, mozhint=False, param='term'): { 'type': 'author', 'label': author.name, - 'url': author.get_absolute_gallery_url() if author.for_pictures else author.get_absolute_url(), + 'url': author.get_absolute_url(), 'img': get_thumbnail(author.photo, '72x72', crop='top').url if author.photo else '', } for author in authors[:limit - len(data)] @@ -71,7 +70,7 @@ def hint(request, mozhint=False, param='term'): { 'type': tag.category, 'label': tag.name, - 'url': tag.get_absolute_gallery_url() if tag.for_pictures else tag.get_absolute_url(), + 'url': tag.get_absolute_url(), } for tag in tags[:limit - len(data)] ]) @@ -101,21 +100,10 @@ def hint(request, mozhint=False, param='term'): 'img': get_thumbnail(b.cover_clean, '72x72').url if b.cover_clean else '', } ) - if len(data) < limit: - arts = picture.models.Picture.objects.filter( - title__iregex='\m' + prefix).only('title', 'id', 'slug') # img? - data.extend([ - { - 'type': 'art', - 'label': art.title, - 'author': art.author_unicode(), - 'url': art.get_absolute_url(), - 'img': get_thumbnail(art.image_file, '72x72').url if art.image_file else '', - } - for art in arts[:limit - len(data)] - ]) if len(data) < limit: infos = infopages.models.InfoPage.objects.filter( + published=True, + findable=True, title_pl__iregex='\m' + prefix).only('title', 'id', 'slug') data.extend([ { @@ -132,6 +120,14 @@ def hint(request, mozhint=False, param='term'): [ item['label'] for item in data + ], + [ + item.get('author', '') + for item in data + ], + [ + item['url'] + for item in data ] ]