From 13f2f447ee06e5a95b86ee6d027b17d209518fdd Mon Sep 17 00:00:00 2001
From: Radek Czajka
{% endfor %}
{% for b in book.get_siblings %}
@@ -141,6 +141,11 @@
{% else %}
{{ book.title }}
+
+ {% for c in book.get_children %}
+
{% endif %}
diff --git a/src/catalogue/templates/catalogue/search_multiple_hits.html b/src/catalogue/templates/catalogue/search_multiple_hits.html
index 137175d80..937b9266d 100644
--- a/src/catalogue/templates/catalogue/search_multiple_hits.html
+++ b/src/catalogue/templates/catalogue/search_multiple_hits.html
@@ -19,7 +19,7 @@
format:
{% if not set.format %}dowolny{% else %}dowolny{% endif %}
{% if set.format == "tekst" %}tekst{% else %}tekst{% endif %}
- {% if set.format == "audio" %}audiobook{% else %}tekst{% endif %}
+ {% if set.format == "audio" %}audiobook{% else %}audiobook{% endif %}
{% if set.format == "synchro" %}DAISY{% else %}DAISY{% endif %}
{% if set.format == "obraz" %}obraz{% else %}obraz{% endif %}
{% trans "epoch" %}: {% if not set.epoch %}dowolna{% else %}dowolna{% endif %} + {% for tag in tags.epoch %} {% if set.epoch == tag.slug %} {{ tag.name }} diff --git a/src/search/index.py b/src/search/index.py index 06d2c4a6e..2be60fdf7 100644 --- a/src/search/index.py +++ b/src/search/index.py @@ -95,7 +95,10 @@ class Snippets(object): of the snippet stored there. """ self.file.seek(pos[0], 0) - txt = self.file.read(pos[1]).decode('utf-8') + try: + txt = self.file.read(pos[1]).decode('utf-8') + except: + return '' return txt def close(self): diff --git a/src/search/views.py b/src/search/views.py index e06b1cc48..b6e290b87 100644 --- a/src/search/views.py +++ b/src/search/views.py @@ -189,9 +189,9 @@ def main(request): 'genre': genre, }, 'tags': { - 'epoch': Tag.objects.filter(category='epoch'), - 'genre': Tag.objects.filter(category='genre'), - 'kind': Tag.objects.filter(category='kind'), + 'epoch': Tag.objects.filter(category='epoch', for_books=True), + 'genre': Tag.objects.filter(category='genre', for_books=True), + 'kind': Tag.objects.filter(category='kind', for_books=True), }, }) @@ -227,11 +227,11 @@ def search_books(query, lang=None, only_audio=False, only_synchro=False, epoch=N def ensure_exists(r): try: - r.book + if not r.book: + return False except Book.DoesNotExist: return False - print(lang, r.book.language) if lang and r.book.language != lang: return False if only_audio and not r.book.has_mp3_file(): @@ -278,7 +278,8 @@ def search_pictures(query, epoch=None, kind=None, genre=None): def ensure_exists(r): try: - return r.picture + if not r.picture: + return False except Picture.DoesNotExist: return False @@ -289,6 +290,8 @@ def search_pictures(query, epoch=None, kind=None, genre=None): if genre and not r.picture.tags.filter(category='genre', slug=genre).exists(): return False + return True + results = [r for r in results if ensure_exists(r)] return results -- 2.20.1