diff --git a/cps/templates/author.html b/cps/templates/author.html index 3135b0d2..ce97d846 100644 --- a/cps/templates/author.html +++ b/cps/templates/author.html @@ -41,13 +41,13 @@
{% for author in entry.authors %} - {% if loop.index > config_authors_max and config_authors_max != 0 %} + {% if loop.index > g.config_authors_max and g.config_authors_max != 0 %} {% if not loop.first %} & {% endif %} {{author.name.replace('|',',')|shortentitle(30)}} {% if loop.last %} - (...) + (...) {% endif %} {% else %} {% if not loop.first %} @@ -91,10 +91,10 @@
{{entry.title|shortentitle}}
{% for author in entry.authors %} - {% if loop.index > config_authors_max and config_authors_max != 0 %} + {% if loop.index > g.config_authors_max and g.config_authors_max != 0 %} {{author.name.replace('|',',')}} {% if loop.last %} - (...) + (...) {% endif %} {% else %} {{author.name.replace('|',',')}} diff --git a/cps/templates/discover.html b/cps/templates/discover.html index b6a72a11..532d53a2 100644 --- a/cps/templates/discover.html +++ b/cps/templates/discover.html @@ -19,13 +19,13 @@
{% for author in entry.authors %} - {% if loop.index > config_authors_max and config_authors_max != 0 %} + {% if loop.index > g.config_authors_max and g.config_authors_max != 0 %} {% if not loop.first %} & {% endif %} {{author.name.replace('|',',')|shortentitle(30)}} {% if loop.last %} - (...) + (...) {% endif %} {% else %} {% if not loop.first %} diff --git a/cps/templates/index.html b/cps/templates/index.html index c05339c4..6a475e22 100755 --- a/cps/templates/index.html +++ b/cps/templates/index.html @@ -21,13 +21,13 @@ web. {% for entry in random %}
{% for author in entry.authors %} - {% if loop.index > config_authors_max and config_authors_max != 0 %} + {% if loop.index > g.config_authors_max and g.config_authors_max != 0 %} {% if not loop.first %} & {% endif %} {{author.name.replace('|',',')|shortentitle(30)}} {% if loop.last %} - (...) + (...) {% endif %} {% else %} {% if not loop.first %} @@ -88,13 +88,13 @@ web. {% for entry in random %}
{% for author in entry.authors %} - {% if loop.index > config_authors_max and config_authors_max != 0 %} + {% if loop.index > g.config_authors_max and g.config_authors_max != 0 %} {% if not loop.first %} & {% endif %} {{author.name.replace('|',',')|shortentitle(30)}} {% if loop.last %} - (...) + (...) {% endif %} {% else %} {% if not loop.first %} diff --git a/cps/templates/list.html b/cps/templates/list.html index 32b463fa..9cdc154d 100644 --- a/cps/templates/list.html +++ b/cps/templates/list.html @@ -5,7 +5,9 @@
{% for author in entry.authors %} - {% if loop.index > config_authors_max and config_authors_max != 0 %} + {% if loop.index > g.config_authors_max and g.config_authors_max != 0 %} {% if not loop.first %} & {% endif %} {{author.name.replace('|',',')|shortentitle(30)}} {% if loop.last %} - (...) + (...) {% endif %} {% else %} {% if not loop.first %} diff --git a/cps/templates/shelf.html b/cps/templates/shelf.html index a382da73..271a02fc 100644 --- a/cps/templates/shelf.html +++ b/cps/templates/shelf.html @@ -31,13 +31,13 @@
{% for author in entry.authors %}
- {% if loop.index > config_authors_max and config_authors_max != 0 %}
+ {% if loop.index > g.config_authors_max and g.config_authors_max != 0 %}
{% if not loop.first %}
&
{% endif %}
{{author.name.replace('|',',')|shortentitle(30)}}
{% if loop.last %}
- (...)
+ (...)
{% endif %}
{% else %}
{% if not loop.first %}
diff --git a/cps/web.py b/cps/web.py
index e64998d4..30794451 100644
--- a/cps/web.py
+++ b/cps/web.py
@@ -36,7 +36,9 @@ from babel import Locale as LC
from babel.dates import format_date
from babel.core import UnknownLocaleError
import base64
-from sqlalchemy.sql import *
+# from sqlalchemy.sql import *
+from sqlalchemy import String as SQLString
+from sqlalchemy.sql.expression import text, func, cast, true, and_, false
import json
import datetime
from iso639 import languages as isoLanguages
@@ -45,7 +47,7 @@ import gdriveutils
from redirect import redirect_back
from cps import lm, babel, ub, config, get_locale, language_table, app, db
from pagination import Pagination
-from sqlalchemy.sql.expression import text
+
feature_support = dict()
try:
@@ -335,6 +337,7 @@ def before_request():
g.allow_registration = config.config_public_reg
g.allow_upload = config.config_uploading
g.current_theme = config.config_theme
+ g.config_authors_max = config.config_authors_max
g.public_shelfes = ub.session.query(ub.Shelf).filter(ub.Shelf.is_public == 1).order_by(ub.Shelf.name).all()
if not config.db_configured and request.endpoint not in ('admin.basic_configuration', 'login') and '/static/' not in request.path:
return redirect(url_for('admin.basic_configuration'))
@@ -494,7 +497,7 @@ def get_matching_tags():
def index(page):
entries, random, pagination = fill_indexpage(page, db.Books, True, [db.Books.timestamp.desc()])
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,
- title=_(u"Recently Added Books"), page="root", config_authors_max=config.config_authors_max)
+ title=_(u"Recently Added Books"), page="root")
@web.route('/books/newest', defaults={'page': 1})
@@ -632,8 +635,7 @@ def author(book_id, page):
app.logger.error('Goodreads website is down/inaccessible')
return render_title_template('author.html', entries=entries, pagination=pagination,
- title=name, author=author_info, other_books=other_books, page="author",
- config_authors_max=config.config_authors_max)
+ title=name, author=author_info, other_books=other_books, page="author")
@web.route("/publisher")
@@ -720,17 +722,16 @@ def series(book_id, page):
abort(404)
+# (cast(db.Ratings.rating/2, SQLString)).label('name'))\
@web.route("/ratings")
@login_required_if_no_ano
def ratings_list():
if current_user.check_visibility(ub.SIDEBAR_RATING):
- entries = db.session.query(db.Series, func.count('books_series_link.book').label('count'))\
- .join(db.books_series_link).join(db.Books).filter(common_filters())\
- .group_by(text('books_series_link.series')).order_by(db.Series.sort).all()
- charlist = db.session.query(func.upper(func.substr(db.Series.sort,1,1)).label('char')) \
- .join(db.books_series_link).join(db.Books).filter(common_filters()) \
- .group_by(func.upper(func.substr(db.Series.sort,1,1))).all()
- return render_title_template('list.html', entries=entries, folder='web.series', charlist=charlist,
+ entries = db.session.query(db.Ratings, func.count('books_ratings_link.book').label('count'),
+ (db.Ratings.rating/2).label('name'))\
+ .join(db.books_ratings_link).join(db.Books).filter(common_filters())\
+ .group_by(text('books_ratings_link.rating')).order_by(db.Ratings.rating).all()
+ return render_title_template('list.html', entries=entries, folder='web.ratings', charlist=list(),
title=_(u"Ratings list"), page="ratingslist")
else:
abort(404)
@@ -740,12 +741,12 @@ def ratings_list():
@web.route("/ratings/