fnp
/
wolnelektury.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
39328e6
)
Fixes
author
Radek Czajka
<rczajka@rczajka.pl>
Thu, 27 Jan 2022 13:50:12 +0000
(14:50 +0100)
committer
Radek Czajka
<rczajka@rczajka.pl>
Thu, 27 Jan 2022 13:50:12 +0000
(14:50 +0100)
src/catalogue/models/book.py
patch
|
blob
|
history
src/catalogue/templates/catalogue/book_text.html
patch
|
blob
|
history
src/catalogue/templates/catalogue/search_multiple_hits.html
patch
|
blob
|
history
src/search/index.py
patch
|
blob
|
history
src/search/views.py
patch
|
blob
|
history
diff --git
a/src/catalogue/models/book.py
b/src/catalogue/models/book.py
index
b1684f9
..
1be9a9f
100644
(file)
--- a/
src/catalogue/models/book.py
+++ b/
src/catalogue/models/book.py
@@
-268,9
+268,17
@@
class Book(models.Model):
sibling = self.parent.children.filter(parent_number__lt=self.parent_number).order_by('-parent_number').first()
if sibling is not None:
return sibling.get_last_text()
sibling = self.parent.children.filter(parent_number__lt=self.parent_number).order_by('-parent_number').first()
if sibling is not None:
return sibling.get_last_text()
+
+ if self.parent.html_file:
+ return self.parent
+
return self.parent.get_prev_text()
def get_next_text(self):
return self.parent.get_prev_text()
def get_next_text(self):
+ child = self.children.order_by('parent_number').first()
+ if child is not None:
+ return child.get_first_text()
+
if not self.parent:
return None
sibling = self.parent.children.filter(parent_number__gt=self.parent_number).order_by('parent_number').first()
if not self.parent:
return None
sibling = self.parent.children.filter(parent_number__gt=self.parent_number).order_by('parent_number').first()
@@
-283,6
+291,9
@@
class Book(models.Model):
return []
return self.parent.children.all().order_by('parent_number')
return []
return self.parent.children.all().order_by('parent_number')
+ def get_children(self):
+ return self.children.all().order_by('parent_number')
+
@property
def name(self):
return self.title
@property
def name(self):
return self.title
diff --git
a/src/catalogue/templates/catalogue/book_text.html
b/src/catalogue/templates/catalogue/book_text.html
index
17c4896
..
158396f
100644
(file)
--- a/
src/catalogue/templates/catalogue/book_text.html
+++ b/
src/catalogue/templates/catalogue/book_text.html
@@
-118,7
+118,7
@@
{% if forloop.counter > 1 %}
<li>
{% endif %}
{% if forloop.counter > 1 %}
<li>
{% endif %}
- <a href="{
{ b.get_absolute_url }
}">{{ b.title }}</a>
+ <a href="{
% if b.html_file %}{% url 'book_text' b.slug %}{% else %}{{ b.get_absolute_url }}{% endif %
}">{{ b.title }}</a>
<ol>
{% endfor %}
{% for b in book.get_siblings %}
<ol>
{% endfor %}
{% for b in book.get_siblings %}
@@
-141,6
+141,11
@@
{% else %}
<strong>{{ book.title }}</strong>
<div id="heretoc"></div>
{% else %}
<strong>{{ book.title }}</strong>
<div id="heretoc"></div>
+ <ol>
+ {% for c in book.get_children %}
+ <li><a href="{% url 'book_text' c.get_first_text.slug %}">{{ c.title }}</a></li>
+ {% endfor %}
+ </ol>
{% endif %}
</div>
{% endif %}
</div>
diff --git
a/src/catalogue/templates/catalogue/search_multiple_hits.html
b/src/catalogue/templates/catalogue/search_multiple_hits.html
index
137175d
..
937b926
100644
(file)
--- a/
src/catalogue/templates/catalogue/search_multiple_hits.html
+++ b/
src/catalogue/templates/catalogue/search_multiple_hits.html
@@
-19,7
+19,7
@@
<strong>format:</strong>
{% if not set.format %}<em>dowolny</em>{% else %}<a href="{% set_get_parameter format='' %}">dowolny</a>{% endif %}
{% if set.format == "tekst" %}<em>tekst</em>{% else %}<a href="{% set_get_parameter format='tekst' %}">tekst</a>{% endif %}
<strong>format:</strong>
{% if not set.format %}<em>dowolny</em>{% else %}<a href="{% set_get_parameter format='' %}">dowolny</a>{% endif %}
{% if set.format == "tekst" %}<em>tekst</em>{% else %}<a href="{% set_get_parameter format='tekst' %}">tekst</a>{% endif %}
- {% if set.format == "audio" %}<em>audiobook</em>{% else %}<a href="{% set_get_parameter format='audio' %}">
tekst
</a>{% endif %}
+ {% if set.format == "audio" %}<em>audiobook</em>{% else %}<a href="{% set_get_parameter format='audio' %}">
audiobook
</a>{% endif %}
{% if set.format == "synchro" %}<em>DAISY</em>{% else %}<a href="{% set_get_parameter format='synchro' %}">DAISY</a>{% endif %}
{% if set.format == "obraz" %}<em>obraz</em>{% else %}<a href="{% set_get_parameter format='obraz' %}">obraz</a>{% endif %}
</p>
{% if set.format == "synchro" %}<em>DAISY</em>{% else %}<a href="{% set_get_parameter format='synchro' %}">DAISY</a>{% endif %}
{% if set.format == "obraz" %}<em>obraz</em>{% else %}<a href="{% set_get_parameter format='obraz' %}">obraz</a>{% endif %}
</p>
@@
-38,6
+38,7
@@
<p class="search-filter">
<strong>{% trans "epoch" %}: </strong>
{% if not set.epoch %}<em>dowolna</em>{% else %}<a href="{% set_get_parameter epoch='' %}">dowolna</a>{% endif %}
<p class="search-filter">
<strong>{% trans "epoch" %}: </strong>
{% if not set.epoch %}<em>dowolna</em>{% else %}<a href="{% set_get_parameter epoch='' %}">dowolna</a>{% endif %}
+
{% for tag in tags.epoch %}
{% if set.epoch == tag.slug %}
<em>{{ tag.name }}</em>
{% for tag in tags.epoch %}
{% if set.epoch == tag.slug %}
<em>{{ tag.name }}</em>
diff --git
a/src/search/index.py
b/src/search/index.py
index
06d2c4a
..
2be60fd
100644
(file)
--- 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)
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):
return txt
def close(self):
diff --git
a/src/search/views.py
b/src/search/views.py
index
e06b1cc
..
b6e290b
100644
(file)
--- a/
src/search/views.py
+++ b/
src/search/views.py
@@
-189,9
+189,9
@@
def main(request):
'genre': genre,
},
'tags': {
'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:
def ensure_exists(r):
try:
- r.book
+ if not r.book:
+ return False
except Book.DoesNotExist:
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():
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:
def ensure_exists(r):
try:
- return r.picture
+ if not r.picture:
+ return False
except Picture.DoesNotExist:
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
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
results = [r for r in results if ensure_exists(r)]
return results