- Fix migration of shelf order
- fix show random books in detail view for authors and series
This commit is contained in:
OzzieIsaacs 2017-02-02 19:36:31 +01:00
parent f21c65ac50
commit 176c7dce70
9 changed files with 23 additions and 13 deletions

View File

@ -15,7 +15,7 @@
<h2>{{entry.title}}</h2>
<p class="author">
{% for author in entry.authors %}
<a href="{{url_for('author', name=author.name) }}">{{author.name}}</a>
<a href="{{url_for('author', name=author.name | urlencode) }}">{{author.name}}</a>
{% if not loop.last %}
&amp;
{% endif %}
@ -65,7 +65,7 @@
<span class="glyphicon glyphicon-tags"></span>
{% for tag in entry.tags %}
<a href="{{ url_for('category', name=tag.name) }}" class="btn btn-xs btn-info" role="button">{{tag.name}}</a>
<a href="{{ url_for('category', name=tag.name | urlencode) }}" class="btn btn-xs btn-info" role="button">{{tag.name}}</a>
{%endfor%}
</div>

View File

@ -9,13 +9,13 @@
<div class="cover">
{% if entry.has_cover is defined %}
<a href="{{ url_for('show_book', id=entry.id) }}">
<img src="{{ url_for('get_cover', cover_path=entry.path) }}" />
<img src="{{ url_for('get_cover', cover_path=entry.path.replace('\\','/')) }}" />
</a>
{% endif %}
</div>
<div class="meta">
<p class="title">{{entry.title|shortentitle}}</p>
<p class="author"><a href="{{url_for('author', name=entry.authors[0].name) }}">{{entry.authors[0].name}}</a></p>
<p class="author"><a href="{{url_for('author', name=entry.authors[0].name | urlencode) }}">{{entry.authors[0].name}}</a></p>
{% if entry.ratings.__len__() > 0 %}
<div class="rating">
{% for number in range((entry.ratings[0].rating/2)|int(2)) %}

View File

@ -55,7 +55,7 @@
<p class="title">{{entry.title|shortentitle}}</p>
<p class="author">
{% for author in entry.authors %}
<a href="{{url_for('author', name=author.name) }}">{{author.name}}</a>
<a href="{{url_for('author', name=author.name | urlencode) }}">{{author.name}}</a>
{% if not loop.last %}
&amp;
{% endif %}

View File

@ -5,7 +5,7 @@
{% for entry in entries %}
<div class="row">
<div class="col-xs-1" align="left"><span class="badge">{{entry.count}}</span></div>
<div class="col-xs-6"><a href="{{url_for(folder, name=entry[0].name)}}">{{entry[0].name}}</a></div>
<div class="col-xs-6"><a href="{{url_for(folder, name=entry[0].name | urlencode)}}">{{entry[0].name}}</a></div>
</div>
{% endfor %}
</div>

View File

@ -16,7 +16,7 @@
<div class="cover">
{% if entry.has_cover is defined %}
<a href="{{ url_for('show_book', id=entry.id) }}">
<img src="{{ url_for('get_cover', cover_path=entry.path) }}" />
<img src="{{ url_for('get_cover', cover_path=entry.path.replace('\\','/')) }}" />
</a>
{% endif %}
</div>
@ -24,7 +24,7 @@
<p class="title">{{entry.title|shortentitle}}</p>
<p class="author">
{% for author in entry.authors %}
<a href="{{url_for('author', name=author.name) }}">{{author.name}}</a>
<a href="{{url_for('author', name=author.name | urlencode) }}">{{author.name}}</a>
{% if not loop.last %}
&amp;
{% endif %}

View File

@ -15,13 +15,13 @@
<div class="cover">
{% if entry.has_cover is defined %}
<a href="{{ url_for('show_book', id=entry.id) }}">
<img src="{{ url_for('get_cover', cover_path=entry.path) }}" />
<img src="{{ url_for('get_cover', cover_path=entry.path.replace('\\','/')) }}" />
</a>
{% endif %}
</div>
<div class="meta">
<p class="title">{{entry.title|shortentitle}}</p>
<p class="author"><a href="{{url_for('author', name=entry.authors[0].name) }}">{{entry.authors[0].name}}</a></p>
<p class="author"><a href="{{url_for('author', name=entry.authors[0].name | urlencode) }}">{{entry.authors[0].name}}</a></p>
{% if entry.ratings.__len__() > 0 %}
<div class="rating">
{% for number in range((entry.ratings[0].rating/2)|int(2)) %}

View File

@ -113,7 +113,7 @@
{% for entry in downloads %}
<div class="col-sm-2">
<a class="pull-left" href="{{ url_for('show_book', id=entry.id) }}">
<img class="media-object" width="100" src="{{ url_for('get_cover', cover_path=entry.path) }}" alt="...">
<img class="media-object" width="100" src="{{ url_for('get_cover', cover_path=entry.path.replace('\\','/')) }}" alt="...">
</a>
</div>
{% endfor %}

View File

@ -330,6 +330,13 @@ def migrate_Database():
conn.execute("ALTER TABLE Settings ADD column `config_anonbrowse` SmallInteger DEFAULT 0")
conn.execute("ALTER TABLE Settings ADD column `config_public_reg` SmallInteger DEFAULT 0")
session.commit()
try:
session.query(exists().where(BookShelf.order)).scalar()
session.commit()
except exc.OperationalError: # Database is not compatible, some rows are missing
conn = engine.connect()
conn.execute("ALTER TABLE book_shelf_link ADD column 'order' INTEGER DEFAULT 1")
session.commit()
try:
create = False
session.query(exists().where(User.sidebar_view)).scalar()

View File

@ -797,7 +797,7 @@ def hot_books(page):
filter = db.Books.languages.any(db.Languages.lang_code == current_user.filter_language())
else:
filter = True
if current_user.show_random_books():
if current_user.show_detail_random():
random = db.session.query(db.Books).filter(filter).order_by(func.random()).limit(config.config_random_books)
else:
random = false
@ -839,11 +839,12 @@ def author_list():
@app.route("/author/<name>")
@login_required_if_no_ano
def author(name):
name=requests.utils.unquote(name)
if current_user.filter_language() != "all":
filter = db.Books.languages.any(db.Languages.lang_code == current_user.filter_language())
else:
filter = True
if current_user.show_random_books():
if current_user.show_detail_random():
random = db.session.query(db.Books).filter(filter).order_by(func.random()).limit(config.config_random_books)
else:
random = false
@ -870,6 +871,7 @@ def series_list():
@app.route("/series/<name>/<int:page>'")
@login_required_if_no_ano
def series(name, page):
name = requests.utils.unquote(name)
entries, random, pagination = fill_indexpage(page, db.Books, db.Books.series.any(db.Series.name == name),
db.Books.series_index)
if entries:
@ -942,6 +944,7 @@ def category_list():
@app.route('/category/<name>/<int:page>')
@login_required_if_no_ano
def category(name, page):
name = requests.utils.unquote(name)
entries, random, pagination = fill_indexpage(page, db.Books, db.Books.tags.any(db.Tags.name == name),
db.Books.timestamp.desc())
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,