From d709c81c503f1c52de5371a7e9d588415c54c0bb Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Fri, 16 Feb 2018 16:27:43 +0100 Subject: [PATCH] search: no tag boxes + smarter pd boxes --- .../catalogue/search_multiple_hits.html | 12 ++++----- src/pdcounter/locale/de/LC_MESSAGES/django.po | 18 ++++++++++++- src/pdcounter/locale/en/LC_MESSAGES/django.po | 12 ++++++++- src/pdcounter/locale/es/LC_MESSAGES/django.po | 18 ++++++++++++- src/pdcounter/locale/fr/LC_MESSAGES/django.po | 12 ++++++++- src/pdcounter/locale/it/LC_MESSAGES/django.po | 12 ++++++++- src/pdcounter/locale/lt/LC_MESSAGES/django.po | 18 ++++++++++++- src/pdcounter/locale/pl/LC_MESSAGES/django.po | 14 +++++++++- src/pdcounter/locale/ru/LC_MESSAGES/django.po | 12 ++++++++- src/pdcounter/locale/uk/LC_MESSAGES/django.po | 18 ++++++++++++- .../templates/pdcounter/pd_author_box.html | 27 +++++++++++++++++++ src/search/views.py | 20 ++++++++------ 12 files changed, 170 insertions(+), 23 deletions(-) create mode 100644 src/pdcounter/templates/pdcounter/pd_author_box.html diff --git a/src/catalogue/templates/catalogue/search_multiple_hits.html b/src/catalogue/templates/catalogue/search_multiple_hits.html index ce43bf9a7..2c3c13958 100644 --- a/src/catalogue/templates/catalogue/search_multiple_hits.html +++ b/src/catalogue/templates/catalogue/search_multiple_hits.html @@ -14,13 +14,13 @@ {% trans "Did you mean" %} {{did_you_mean|lower}}? {% endif %} -
- {% if tags %} +
+ {% if pd_authors %}
- {% for tag in tags %} - - {% include "catalogue/tag_box.html" %} - + {% for author in pd_authors %} +
+ {% include "pdcounter/pd_author_box.html" %} +
{% endfor %}
{% endif %} diff --git a/src/pdcounter/locale/de/LC_MESSAGES/django.po b/src/pdcounter/locale/de/LC_MESSAGES/django.po index 3d5a83ee6..36420eb42 100644 --- a/src/pdcounter/locale/de/LC_MESSAGES/django.po +++ b/src/pdcounter/locale/de/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-09-14 12:34+0200\n" +"POT-Creation-Date: 2018-02-16 16:17+0100\n" "PO-Revision-Date: 2012-04-15 13:43+0100\n" "Last-Translator: Kamil \n" "Language-Team: \n" @@ -80,11 +80,14 @@ msgid "Read article about this author on Wikipedia" msgstr "Lesen Sie einen Artikel über diesem Autor in Wikipedia" #: templates/pdcounter/author_detail.html:40 +#: templates/pdcounter/pd_author_box.html:9 msgid "This author's works are copyrighted." msgstr "Die Urheberrechte für dieses Werk werden geschützt." #: templates/pdcounter/author_detail.html:41 #: templates/pdcounter/author_detail.html:53 +#: templates/pdcounter/pd_author_box.html:10 +#: templates/pdcounter/pd_author_box.html:21 msgid "" "Find out why Internet libraries can't publish this author's works." @@ -94,6 +97,7 @@ msgstr "" "dürfen." #: templates/pdcounter/author_detail.html:45 +#: templates/pdcounter/pd_author_box.html:14 #, fuzzy msgid "" "This author's works are in public domain and will be published on Internet " @@ -140,5 +144,17 @@ msgstr "" msgid "This work is copyrighted." msgstr "Dieses Werk wird durch das Urheberrecht geschützt." +#: templates/pdcounter/pd_author_box.html:18 +#, fuzzy +#| msgid "" +#| "This author's works will become part of public domain and will be allowed " +#| "to be published without restrictions in" +msgid "" +"This author's works will become part of public domain and will be allowed to " +"be published without restrictions in the year" +msgstr "" +"Die Werke des Autors werden in Public Domain sein und werden unbegrenzt " +"publeziert werden dürfen in" + #~ msgid "year of translator's death" #~ msgstr "Todesjahr des Übersetzers" diff --git a/src/pdcounter/locale/en/LC_MESSAGES/django.po b/src/pdcounter/locale/en/LC_MESSAGES/django.po index b1f6b936b..6d85c934b 100644 --- a/src/pdcounter/locale/en/LC_MESSAGES/django.po +++ b/src/pdcounter/locale/en/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-09-14 12:34+0200\n" +"POT-Creation-Date: 2018-02-16 16:17+0100\n" "PO-Revision-Date: 2012-03-04 20:05+0100\n" "Last-Translator: xxx \n" "Language-Team: LANGUAGE \n" @@ -81,17 +81,21 @@ msgid "Read article about this author on Wikipedia" msgstr "" #: templates/pdcounter/author_detail.html:40 +#: templates/pdcounter/pd_author_box.html:9 msgid "This author's works are copyrighted." msgstr "" #: templates/pdcounter/author_detail.html:41 #: templates/pdcounter/author_detail.html:53 +#: templates/pdcounter/pd_author_box.html:10 +#: templates/pdcounter/pd_author_box.html:21 msgid "" "Find out why Internet libraries can't publish this author's works." msgstr "" #: templates/pdcounter/author_detail.html:45 +#: templates/pdcounter/pd_author_box.html:14 msgid "" "This author's works are in public domain and will be published on Internet " "library of Wolne Lektury soon." @@ -126,5 +130,11 @@ msgstr "" msgid "This work is copyrighted." msgstr "" +#: templates/pdcounter/pd_author_box.html:18 +msgid "" +"This author's works will become part of public domain and will be allowed to " +"be published without restrictions in the year" +msgstr "" + #~ msgid "year of translator's death" #~ msgstr "Year of translator's death" diff --git a/src/pdcounter/locale/es/LC_MESSAGES/django.po b/src/pdcounter/locale/es/LC_MESSAGES/django.po index b00b79ac7..2ee1fbe83 100644 --- a/src/pdcounter/locale/es/LC_MESSAGES/django.po +++ b/src/pdcounter/locale/es/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-09-14 12:34+0200\n" +"POT-Creation-Date: 2018-02-16 16:17+0100\n" "PO-Revision-Date: 2012-05-17 22:05+0100\n" "Last-Translator: KG \n" "Language-Team: LANGUAGE \n" @@ -79,11 +79,14 @@ msgid "Read article about this author on Wikipedia" msgstr "Lea el artículo sobre este autor en Wikipedia" #: templates/pdcounter/author_detail.html:40 +#: templates/pdcounter/pd_author_box.html:9 msgid "This author's works are copyrighted." msgstr "Las obras de este autor tienen todos los derechos de autor reservados." #: templates/pdcounter/author_detail.html:41 #: templates/pdcounter/author_detail.html:53 +#: templates/pdcounter/pd_author_box.html:10 +#: templates/pdcounter/pd_author_box.html:21 msgid "" "Find out why Internet libraries can't publish this author's works." @@ -93,6 +96,7 @@ msgstr "" "autor." #: templates/pdcounter/author_detail.html:45 +#: templates/pdcounter/pd_author_box.html:14 #, fuzzy msgid "" "This author's works are in public domain and will be published on Internet " @@ -139,5 +143,17 @@ msgstr "" msgid "This work is copyrighted." msgstr "Esta obra tiene todos los derechos de autor reservados." +#: templates/pdcounter/pd_author_box.html:18 +#, fuzzy +#| msgid "" +#| "This author's works will become part of public domain and will be allowed " +#| "to be published without restrictions in" +msgid "" +"This author's works will become part of public domain and will be allowed to " +"be published without restrictions in the year" +msgstr "" +"Las obras de este autor van a ser parte de dominio público y pronto serán " +"publicadas sin restricciones en" + #~ msgid "year of translator's death" #~ msgstr "año de la muerte del traductor" diff --git a/src/pdcounter/locale/fr/LC_MESSAGES/django.po b/src/pdcounter/locale/fr/LC_MESSAGES/django.po index 99b695b61..7949f08bc 100644 --- a/src/pdcounter/locale/fr/LC_MESSAGES/django.po +++ b/src/pdcounter/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-09-14 12:34+0200\n" +"POT-Creation-Date: 2018-02-16 16:17+0100\n" "PO-Revision-Date: 2012-02-22 20:58+0100\n" "Last-Translator: Ela Janota \n" "Language-Team: LANGUAGE \n" @@ -78,17 +78,21 @@ msgid "Read article about this author on Wikipedia" msgstr "" #: templates/pdcounter/author_detail.html:40 +#: templates/pdcounter/pd_author_box.html:9 msgid "This author's works are copyrighted." msgstr "" #: templates/pdcounter/author_detail.html:41 #: templates/pdcounter/author_detail.html:53 +#: templates/pdcounter/pd_author_box.html:10 +#: templates/pdcounter/pd_author_box.html:21 msgid "" "Find out why Internet libraries can't publish this author's works." msgstr "" #: templates/pdcounter/author_detail.html:45 +#: templates/pdcounter/pd_author_box.html:14 msgid "" "This author's works are in public domain and will be published on Internet " "library of Wolne Lektury soon." @@ -123,5 +127,11 @@ msgstr "" msgid "This work is copyrighted." msgstr "" +#: templates/pdcounter/pd_author_box.html:18 +msgid "" +"This author's works will become part of public domain and will be allowed to " +"be published without restrictions in the year" +msgstr "" + #~ msgid "year of translator's death" #~ msgstr "année de la mort du traducteur" diff --git a/src/pdcounter/locale/it/LC_MESSAGES/django.po b/src/pdcounter/locale/it/LC_MESSAGES/django.po index 7afb27eb9..7a233e0bb 100644 --- a/src/pdcounter/locale/it/LC_MESSAGES/django.po +++ b/src/pdcounter/locale/it/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-09-14 12:34+0200\n" +"POT-Creation-Date: 2018-02-16 16:17+0100\n" "PO-Revision-Date: 2012-02-21 17:06+0100\n" "Last-Translator: xxx\n" "Language-Team: LANGUAGE \n" @@ -79,17 +79,21 @@ msgid "Read article about this author on Wikipedia" msgstr "" #: templates/pdcounter/author_detail.html:40 +#: templates/pdcounter/pd_author_box.html:9 msgid "This author's works are copyrighted." msgstr "" #: templates/pdcounter/author_detail.html:41 #: templates/pdcounter/author_detail.html:53 +#: templates/pdcounter/pd_author_box.html:10 +#: templates/pdcounter/pd_author_box.html:21 msgid "" "Find out why Internet libraries can't publish this author's works." msgstr "" #: templates/pdcounter/author_detail.html:45 +#: templates/pdcounter/pd_author_box.html:14 msgid "" "This author's works are in public domain and will be published on Internet " "library of Wolne Lektury soon." @@ -124,6 +128,12 @@ msgstr "" msgid "This work is copyrighted." msgstr "" +#: templates/pdcounter/pd_author_box.html:18 +msgid "" +"This author's works will become part of public domain and will be allowed to " +"be published without restrictions in the year" +msgstr "" + #~ msgid "tags" #~ msgstr "i tag" diff --git a/src/pdcounter/locale/lt/LC_MESSAGES/django.po b/src/pdcounter/locale/lt/LC_MESSAGES/django.po index 8ad5ad435..5620be1f9 100644 --- a/src/pdcounter/locale/lt/LC_MESSAGES/django.po +++ b/src/pdcounter/locale/lt/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-09-14 12:34+0200\n" +"POT-Creation-Date: 2018-02-16 16:17+0100\n" "PO-Revision-Date: 2012-04-03 18:01+0100\n" "Last-Translator: Karolina Zuber \n" "Language-Team: LANGUAGE \n" @@ -81,11 +81,14 @@ msgid "Read article about this author on Wikipedia" msgstr "Skaitykite straipsnį apie šį autorių Vikipedijoje" #: templates/pdcounter/author_detail.html:40 +#: templates/pdcounter/pd_author_box.html:9 msgid "This author's works are copyrighted." msgstr "Šio autoriaus kūriniai yra autorinių teisių saugomi." #: templates/pdcounter/author_detail.html:41 #: templates/pdcounter/author_detail.html:53 +#: templates/pdcounter/pd_author_box.html:10 +#: templates/pdcounter/pd_author_box.html:21 msgid "" "Find out why Internet libraries can't publish this author's works." @@ -95,6 +98,7 @@ msgstr "" "publikuojami internetinėje bibliotekoje." #: templates/pdcounter/author_detail.html:45 +#: templates/pdcounter/pd_author_box.html:14 #, fuzzy msgid "" "This author's works are in public domain and will be published on Internet " @@ -142,5 +146,17 @@ msgstr "" msgid "This work is copyrighted." msgstr "Šis kūrinis yra autorinių teisių saugomas." +#: templates/pdcounter/pd_author_box.html:18 +#, fuzzy +#| msgid "" +#| "This author's works will become part of public domain and will be allowed " +#| "to be published without restrictions in" +msgid "" +"This author's works will become part of public domain and will be allowed to " +"be published without restrictions in the year" +msgstr "" +"Šio autoriaus kūriniai netrukus bus viešai prieinami ir galės būti " +"publikuojami be apribojimų" + #~ msgid "year of translator's death" #~ msgstr "vertėjo mirimo metai" diff --git a/src/pdcounter/locale/pl/LC_MESSAGES/django.po b/src/pdcounter/locale/pl/LC_MESSAGES/django.po index 4926cf8f7..da4b180a5 100644 --- a/src/pdcounter/locale/pl/LC_MESSAGES/django.po +++ b/src/pdcounter/locale/pl/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-09-14 12:34+0200\n" +"POT-Creation-Date: 2018-02-16 16:17+0100\n" "PO-Revision-Date: 2013-06-11 15:47+0100\n" "Last-Translator: Radek Czajka \n" "Language-Team: LANGUAGE \n" @@ -80,11 +80,14 @@ msgid "Read article about this author on Wikipedia" msgstr "Przeczytaj artykuł o autorze w Wikipedii" #: templates/pdcounter/author_detail.html:40 +#: templates/pdcounter/pd_author_box.html:9 msgid "This author's works are copyrighted." msgstr "Dzieła tego autora objęte są prawem autorskim." #: templates/pdcounter/author_detail.html:41 #: templates/pdcounter/author_detail.html:53 +#: templates/pdcounter/pd_author_box.html:10 +#: templates/pdcounter/pd_author_box.html:21 msgid "" "Find out why Internet libraries can't publish this author's works." @@ -94,6 +97,7 @@ msgstr "" "autora." #: templates/pdcounter/author_detail.html:45 +#: templates/pdcounter/pd_author_box.html:14 msgid "" "This author's works are in public domain and will be published on Internet " "library of Wolne Lektury soon." @@ -138,5 +142,13 @@ msgstr "" msgid "This work is copyrighted." msgstr "Ten utwór objęty jest prawem autorskim." +#: templates/pdcounter/pd_author_box.html:18 +msgid "" +"This author's works will become part of public domain and will be allowed to " +"be published without restrictions in the year" +msgstr "" +"Dzieła tego autora przejdą do zasobów domeny publicznej i będą mogły być " +"publikowane bez żadnych ograniczeń w roku" + #~ msgid "year of translator's death" #~ msgstr "rok śmierci tłumacza" diff --git a/src/pdcounter/locale/ru/LC_MESSAGES/django.po b/src/pdcounter/locale/ru/LC_MESSAGES/django.po index 9e49ad405..2c3259105 100644 --- a/src/pdcounter/locale/ru/LC_MESSAGES/django.po +++ b/src/pdcounter/locale/ru/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-09-14 12:34+0200\n" +"POT-Creation-Date: 2018-02-16 16:17+0100\n" "PO-Revision-Date: 2012-03-04 22:11+0100\n" "Last-Translator: xxx \n" "Language-Team: LANGUAGE \n" @@ -79,17 +79,21 @@ msgid "Read article about this author on Wikipedia" msgstr "" #: templates/pdcounter/author_detail.html:40 +#: templates/pdcounter/pd_author_box.html:9 msgid "This author's works are copyrighted." msgstr "" #: templates/pdcounter/author_detail.html:41 #: templates/pdcounter/author_detail.html:53 +#: templates/pdcounter/pd_author_box.html:10 +#: templates/pdcounter/pd_author_box.html:21 msgid "" "Find out why Internet libraries can't publish this author's works." msgstr "" #: templates/pdcounter/author_detail.html:45 +#: templates/pdcounter/pd_author_box.html:14 msgid "" "This author's works are in public domain and will be published on Internet " "library of Wolne Lektury soon." @@ -124,5 +128,11 @@ msgstr "" msgid "This work is copyrighted." msgstr "" +#: templates/pdcounter/pd_author_box.html:18 +msgid "" +"This author's works will become part of public domain and will be allowed to " +"be published without restrictions in the year" +msgstr "" + #~ msgid "year of translator's death" #~ msgstr "год смерти переводчика" diff --git a/src/pdcounter/locale/uk/LC_MESSAGES/django.po b/src/pdcounter/locale/uk/LC_MESSAGES/django.po index 224bed81d..44bd06e88 100644 --- a/src/pdcounter/locale/uk/LC_MESSAGES/django.po +++ b/src/pdcounter/locale/uk/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-09-14 12:34+0200\n" +"POT-Creation-Date: 2018-02-16 16:17+0100\n" "PO-Revision-Date: 2012-05-28 14:18+0100\n" "Last-Translator: Natalia Kertyczak \n" "Language-Team: LANGUAGE \n" @@ -78,11 +78,14 @@ msgid "Read article about this author on Wikipedia" msgstr "Прочитати статтю про автора у Вікіпедії" #: templates/pdcounter/author_detail.html:40 +#: templates/pdcounter/pd_author_box.html:9 msgid "This author's works are copyrighted." msgstr "Твори цього автора охороняються авторським правом." #: templates/pdcounter/author_detail.html:41 #: templates/pdcounter/author_detail.html:53 +#: templates/pdcounter/pd_author_box.html:10 +#: templates/pdcounter/pd_author_box.html:21 msgid "" "Find out why Internet libraries can't publish this author's works." @@ -92,6 +95,7 @@ msgstr "" "опублікувати творів цього автора." #: templates/pdcounter/author_detail.html:45 +#: templates/pdcounter/pd_author_box.html:14 #, fuzzy msgid "" "This author's works are in public domain and will be published on Internet " @@ -139,5 +143,17 @@ msgstr "" msgid "This work is copyrighted." msgstr "Цей твір охороняється авторським правом." +#: templates/pdcounter/pd_author_box.html:18 +#, fuzzy +#| msgid "" +#| "This author's works will become part of public domain and will be allowed " +#| "to be published without restrictions in" +msgid "" +"This author's works will become part of public domain and will be allowed to " +"be published without restrictions in the year" +msgstr "" +"Твори цього автора стануть частиною суспільного надбання і можна буде їх " +"вільно публікувати у" + #~ msgid "year of translator's death" #~ msgstr "рік смерті перекладача" diff --git a/src/pdcounter/templates/pdcounter/pd_author_box.html b/src/pdcounter/templates/pdcounter/pd_author_box.html new file mode 100644 index 000000000..c5eb20bc3 --- /dev/null +++ b/src/pdcounter/templates/pdcounter/pd_author_box.html @@ -0,0 +1,27 @@ +{% spaceless %} + {% load i18n %} + {% load catalogue_tags %} + +
+

{{ author.name }}

+ {% if author.alive %} +

+ {% trans "This author's works are copyrighted." %} + {% trans "Find out why Internet libraries can't publish this author's works." %} +

+ {% else %} + {% if author.in_pd %} +

{% trans "This author's works are in public domain and will be published on Internet library of Wolne Lektury soon." %}

+ {% else %} +
+

+ {% trans "This author's works will become part of public domain and will be allowed to be published without restrictions in the year" %} {{ author.goes_to_pd }}. +

+

+ {% trans "Find out why Internet libraries can't publish this author's works." %} +

+
+ {% endif %} + {% endif %} +
+{% endspaceless %} diff --git a/src/search/views.py b/src/search/views.py index 7e512be14..bda24b0dd 100644 --- a/src/search/views.py +++ b/src/search/views.py @@ -3,13 +3,14 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from django.conf import settings +from django.http.response import HttpResponseRedirect from django.shortcuts import render_to_response from django.template import RequestContext from django.views.decorators import cache from django.http import HttpResponse, JsonResponse -from catalogue.utils import split_tags from catalogue.models import Book, Tag +from pdcounter.models import Author from search.index import Search, SearchResult from suggest.forms import PublishingSuggestForm import re @@ -126,8 +127,11 @@ def main(request): search = Search() - tags = search.hint_tags(query, pdcounter=True, prefix=False) - tags = split_tags(tags) + pd_authors = Author.objects.filter(name__icontains=query) + existing_slugs = Tag.objects.filter( + category='author', slug__in=list(pd_authors.values_list('slug', flat=True)))\ + .values_list('slug', flat=True) + pd_authors = pd_authors.exclude(slug__in=existing_slugs) results_parts = [] @@ -166,23 +170,23 @@ def main(request): results = filter(ensure_exists, results) - if not results: + if not results and not pd_authors: form = PublishingSuggestForm(initial={"books": query + ", "}) return render_to_response( 'catalogue/search_no_hits.html', { - 'tags': tags, - 'prefix': query, 'form': form, 'did_you_mean': suggestion }, context_instance=RequestContext(request)) + if not results and len(pd_authors) == 1: + return HttpResponseRedirect(pd_authors[0].get_absolute_url()) + return render_to_response( 'catalogue/search_multiple_hits.html', { - 'tags': tags['author'] + tags['kind'] + tags['genre'] + tags['epoch'] + tags['theme'], - 'prefix': query, + 'pd_authors': pd_authors, 'results': results, 'did_you_mean': suggestion }, -- 2.20.1