From 176c7dce708a19c318ad04265ecbbeea980807e8 Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Thu, 2 Feb 2017 19:36:31 +0100 Subject: [PATCH] - Fix for #100 - Fix migration of shelf order - fix show random books in detail view for authors and series --- cps/templates/detail.html | 4 ++-- cps/templates/discover.html | 4 ++-- cps/templates/index.html | 2 +- cps/templates/list.html | 2 +- cps/templates/search.html | 4 ++-- cps/templates/shelf.html | 4 ++-- cps/templates/user_edit.html | 2 +- cps/ub.py | 7 +++++++ cps/web.py | 7 +++++-- 9 files changed, 23 insertions(+), 13 deletions(-) diff --git a/cps/templates/detail.html b/cps/templates/detail.html index a7b8c78e..753db662 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -15,7 +15,7 @@

{{entry.title}}

{% for author in entry.authors %} - {{author.name}} + {{author.name}} {% if not loop.last %} & {% endif %} @@ -65,7 +65,7 @@ {% for tag in entry.tags %} - {{tag.name}} + {{tag.name}} {%endfor%} diff --git a/cps/templates/discover.html b/cps/templates/discover.html index fb76172e..51157972 100644 --- a/cps/templates/discover.html +++ b/cps/templates/discover.html @@ -9,13 +9,13 @@

{% if entry.has_cover is defined %} - + {% endif %}

{{entry.title|shortentitle}}

-

{{entry.authors[0].name}}

+

{{entry.authors[0].name}}

{% if entry.ratings.__len__() > 0 %}
{% for number in range((entry.ratings[0].rating/2)|int(2)) %} diff --git a/cps/templates/index.html b/cps/templates/index.html index 9abbaff1..835bde23 100755 --- a/cps/templates/index.html +++ b/cps/templates/index.html @@ -55,7 +55,7 @@

{{entry.title|shortentitle}}

{% for author in entry.authors %} - {{author.name}} + {{author.name}} {% if not loop.last %} & {% endif %} diff --git a/cps/templates/list.html b/cps/templates/list.html index 07911535..412f9196 100644 --- a/cps/templates/list.html +++ b/cps/templates/list.html @@ -5,7 +5,7 @@ {% for entry in entries %}

{{entry.count}}
- +
{% endfor %}
diff --git a/cps/templates/search.html b/cps/templates/search.html index 75f3aa7c..efdf40b9 100644 --- a/cps/templates/search.html +++ b/cps/templates/search.html @@ -16,7 +16,7 @@
{% if entry.has_cover is defined %} - + {% endif %}
@@ -24,7 +24,7 @@

{{entry.title|shortentitle}}

{% for author in entry.authors %} - {{author.name}} + {{author.name}} {% if not loop.last %} & {% endif %} diff --git a/cps/templates/shelf.html b/cps/templates/shelf.html index 4f8a5f94..4c23f827 100644 --- a/cps/templates/shelf.html +++ b/cps/templates/shelf.html @@ -15,13 +15,13 @@

{% if entry.has_cover is defined %} - + {% endif %}

{{entry.title|shortentitle}}

-

{{entry.authors[0].name}}

+

{{entry.authors[0].name}}

{% if entry.ratings.__len__() > 0 %}
{% for number in range((entry.ratings[0].rating/2)|int(2)) %} diff --git a/cps/templates/user_edit.html b/cps/templates/user_edit.html index 674ca2aa..8e4e0c8c 100644 --- a/cps/templates/user_edit.html +++ b/cps/templates/user_edit.html @@ -113,7 +113,7 @@ {% for entry in downloads %} {% endfor %} diff --git a/cps/ub.py b/cps/ub.py index 183ea26e..b68e0598 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -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() diff --git a/cps/web.py b/cps/web.py index 9443c7e0..36cf971b 100755 --- a/cps/web.py +++ b/cps/web.py @@ -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/") @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//'") @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//') @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,