Update ratings

pull/932/head
Ozzieisaacs 6 years ago
parent 6d2270d931
commit 4a33278596

@ -41,13 +41,13 @@
</a> </a>
<p class="author"> <p class="author">
{% for author in entry.authors %} {% 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 %} {% if not loop.first %}
<span class="author-hidden-divider">&amp;</span> <span class="author-hidden-divider">&amp;</span>
{% endif %} {% endif %}
<a class="author-name author-hidden" href="{{url_for('web.author', book_id=author.id) }}">{{author.name.replace('|',',')|shortentitle(30)}}</a> <a class="author-name author-hidden" href="{{url_for('web.author', book_id=author.id) }}">{{author.name.replace('|',',')|shortentitle(30)}}</a>
{% if loop.last %} {% if loop.last %}
<a href="#" class="author-expand" data-authors-max="{{config_authors_max}}" data-collapse-caption="({{_('reduce')}})">(...)</a> <a href="#" class="author-expand" data-authors-max="{{g.config_authors_max}}" data-collapse-caption="({{_('reduce')}})">(...)</a>
{% endif %} {% endif %}
{% else %} {% else %}
{% if not loop.first %} {% if not loop.first %}
@ -91,10 +91,10 @@
<p class="title">{{entry.title|shortentitle}}</p> <p class="title">{{entry.title|shortentitle}}</p>
<p class="author"> <p class="author">
{% for author in entry.authors %} {% 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 %}
<a class="author-name author-hidden" href="https://www.goodreads.com/author/show/{{ author.gid }}" target="_blank" rel="noopener">{{author.name.replace('|',',')}}</a> <a class="author-name author-hidden" href="https://www.goodreads.com/author/show/{{ author.gid }}" target="_blank" rel="noopener">{{author.name.replace('|',',')}}</a>
{% if loop.last %} {% if loop.last %}
<a href="#" class="author-expand" data-authors-max="{{config_authors_max}}" data-collapse-caption="({{_('reduce')}})">(...)</a> <a href="#" class="author-expand" data-authors-max="{{g.config_authors_max}}" data-collapse-caption="({{_('reduce')}})">(...)</a>
{% endif %} {% endif %}
{% else %} {% else %}
<a class="author-name" href="https://www.goodreads.com/author/show/{{ author.gid }}" target="_blank" rel="noopener">{{author.name.replace('|',',')}}</a> <a class="author-name" href="https://www.goodreads.com/author/show/{{ author.gid }}" target="_blank" rel="noopener">{{author.name.replace('|',',')}}</a>

@ -19,13 +19,13 @@
</a> </a>
<p class="author"> <p class="author">
{% for author in entry.authors %} {% 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 %} {% if not loop.first %}
<span class="author-hidden-divider">&amp;</span> <span class="author-hidden-divider">&amp;</span>
{% endif %} {% endif %}
<a class="author-name author-hidden" href="{{url_for('web.author', book_id=author.id) }}">{{author.name.replace('|',',')|shortentitle(30)}}</a> <a class="author-name author-hidden" href="{{url_for('web.author', book_id=author.id) }}">{{author.name.replace('|',',')|shortentitle(30)}}</a>
{% if loop.last %} {% if loop.last %}
<a href="#" class="author-expand" data-authors-max="{{config_authors_max}}" data-collapse-caption="({{_('reduce')}})">(...)</a> <a href="#" class="author-expand" data-authors-max="{{g.config_authors_max}}" data-collapse-caption="({{_('reduce')}})">(...)</a>
{% endif %} {% endif %}
{% else %} {% else %}
{% if not loop.first %} {% if not loop.first %}

@ -21,13 +21,13 @@ web. {% for entry in random %}
</a> </a>
<p class="author"> <p class="author">
{% for author in entry.authors %} {% 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 %} {% if not loop.first %}
<span class="author-hidden-divider">&amp;</span> <span class="author-hidden-divider">&amp;</span>
{% endif %} {% endif %}
<a class="author-name author-hidden" href="{{url_for('web.author', book_id=author.id) }}">{{author.name.replace('|',',')|shortentitle(30)}}</a> <a class="author-name author-hidden" href="{{url_for('web.author', book_id=author.id) }}">{{author.name.replace('|',',')|shortentitle(30)}}</a>
{% if loop.last %} {% if loop.last %}
<a href="#" class="author-expand" data-authors-max="{{config_authors_max}}" data-collapse-caption="({{_('reduce')}})">(...)</a> <a href="#" class="author-expand" data-authors-max="{{g.config_authors_max}}" data-collapse-caption="({{_('reduce')}})">(...)</a>
{% endif %} {% endif %}
{% else %} {% else %}
{% if not loop.first %} {% if not loop.first %}
@ -88,13 +88,13 @@ web. {% for entry in random %}
</a> </a>
<p class="author"> <p class="author">
{% for author in entry.authors %} {% 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 %} {% if not loop.first %}
<span class="author-hidden-divider">&amp;</span> <span class="author-hidden-divider">&amp;</span>
{% endif %} {% endif %}
<a class="author-name author-hidden" href="{{url_for('web.author', book_id=author.id) }}">{{author.name.replace('|',',')|shortentitle(30)}}</a> <a class="author-name author-hidden" href="{{url_for('web.author', book_id=author.id) }}">{{author.name.replace('|',',')|shortentitle(30)}}</a>
{% if loop.last %} {% if loop.last %}
<a href="#" class="author-expand" data-authors-max="{{config_authors_max}}" data-collapse-caption="({{_('reduce')}})">(...)</a> <a href="#" class="author-expand" data-authors-max="{{g.config_authors_max}}" data-collapse-caption="({{_('reduce')}})">(...)</a>
{% endif %} {% endif %}
{% else %} {% else %}
{% if not loop.first %} {% if not loop.first %}

@ -5,7 +5,9 @@
<div class="filterheader hidden-xs hidden-sm"> <div class="filterheader hidden-xs hidden-sm">
<button id="desc" class="btn btn-success"><span class="glyphicon glyphicon-sort-by-alphabet"></span></button> <button id="desc" class="btn btn-success"><span class="glyphicon glyphicon-sort-by-alphabet"></span></button>
<button id="asc" class="btn btn-success"><span class="glyphicon glyphicon-sort-by-alphabet-alt"></span></button> <button id="asc" class="btn btn-success"><span class="glyphicon glyphicon-sort-by-alphabet-alt"></span></button>
{% if charlist|length %}
<button id="all" class="btn btn-success">{{_('All')}}</button> <button id="all" class="btn btn-success">{{_('All')}}</button>
{% endif %}
<div class="btn-group character" role="group"> <div class="btn-group character" role="group">
{% for char in charlist%} {% for char in charlist%}
<button class="btn btn-success char">{{char.char}}</button> <button class="btn btn-success char">{{char.char}}</button>
@ -15,9 +17,21 @@
<div class="container"> <div class="container">
<div id="list" class="col-xs-12 col-sm-6"> <div id="list" class="col-xs-12 col-sm-6">
{% for entry in entries %} {% for entry in entries %}
<div class="row" data-id="{% if entry[0].sort %}{{entry[0].sort}}{% else %}{{entry[0].name}}{% endif %}"> <div class="row" data-id="{% if entry[0].sort %}{{entry[0].sort}}{% else %}{% if entry.name %}{{entry.name}}{% else %}{{entry[0].name}}{% endif %}{% endif %}">
<div class="col-xs-2 col-sm-2 col-md-1" align="left"><span class="badge">{{entry.count}}</span></div> <div class="col-xs-2 col-sm-2 col-md-1" align="left"><span class="badge">{{entry.count}}</span></div>
<div class="col-xs-10 col-sm-10 col-md-11"><a id="list_{{loop.index0}}" href="{{url_for(folder, book_id=entry[0].id )}}">{{entry[0].name}}</a></div> <div class="col-xs-10 col-sm-10 col-md-11"><a id="list_{{loop.index0}}" href="{{url_for(folder, book_id=entry[0].id )}}">
{% if entry.name %}
<div class="rating">
{% for number in range(entry.name) %}
<span class="glyphicon glyphicon-star good"></span>
{% if loop.last and loop.index < 5 %}
{% for numer in range(5 - loop.index) %}
<span class="glyphicon glyphicon-star"></span>
{% endfor %}
{% endif %}
{% endfor %}
</div>
{% else %} {{entry[0].name}}{% endif %}</a></div>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>

@ -46,13 +46,13 @@
</a> </a>
<p class="author"> <p class="author">
{% for author in entry.authors %} {% 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 %} {% if not loop.first %}
<span class="author-hidden-divider">&amp;</span> <span class="author-hidden-divider">&amp;</span>
{% endif %} {% endif %}
<a class="author-name author-hidden" href="{{url_for('web.author', book_id=author.id) }}">{{author.name.replace('|',',')|shortentitle(30)}}</a> <a class="author-name author-hidden" href="{{url_for('web.author', book_id=author.id) }}">{{author.name.replace('|',',')|shortentitle(30)}}</a>
{% if loop.last %} {% if loop.last %}
<a href="#" class="author-expand" data-authors-max="{{config_authors_max}}" data-collapse-caption="({{_('reduce')}})">(...)</a> <a href="#" class="author-expand" data-authors-max="{{g.config_authors_max}}" data-collapse-caption="({{_('reduce')}})">(...)</a>
{% endif %} {% endif %}
{% else %} {% else %}
{% if not loop.first %} {% if not loop.first %}

@ -31,13 +31,13 @@
</a> </a>
<p class="author"> <p class="author">
{% for author in entry.authors %} {% 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 %} {% if not loop.first %}
<span class="author-hidden-divider">&amp;</span> <span class="author-hidden-divider">&amp;</span>
{% endif %} {% endif %}
<a class="author-name author-hidden" href="{{url_for('web.author', book_id=author.id) }}">{{author.name.replace('|',',')|shortentitle(30)}}</a> <a class="author-name author-hidden" href="{{url_for('web.author', book_id=author.id) }}">{{author.name.replace('|',',')|shortentitle(30)}}</a>
{% if loop.last %} {% if loop.last %}
<a href="#" class="author-expand" data-authors-max="{{config_authors_max}}" data-collapse-caption="({{_('reduce')}})">(...)</a> <a href="#" class="author-expand" data-authors-max="{{g.config_authors_max}}" data-collapse-caption="({{_('reduce')}})">(...)</a>
{% endif %} {% endif %}
{% else %} {% else %}
{% if not loop.first %} {% if not loop.first %}

@ -36,7 +36,9 @@ from babel import Locale as LC
from babel.dates import format_date from babel.dates import format_date
from babel.core import UnknownLocaleError from babel.core import UnknownLocaleError
import base64 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 json
import datetime import datetime
from iso639 import languages as isoLanguages from iso639 import languages as isoLanguages
@ -45,7 +47,7 @@ import gdriveutils
from redirect import redirect_back from redirect import redirect_back
from cps import lm, babel, ub, config, get_locale, language_table, app, db from cps import lm, babel, ub, config, get_locale, language_table, app, db
from pagination import Pagination from pagination import Pagination
from sqlalchemy.sql.expression import text
feature_support = dict() feature_support = dict()
try: try:
@ -335,6 +337,7 @@ def before_request():
g.allow_registration = config.config_public_reg g.allow_registration = config.config_public_reg
g.allow_upload = config.config_uploading g.allow_upload = config.config_uploading
g.current_theme = config.config_theme 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() 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: 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')) return redirect(url_for('admin.basic_configuration'))
@ -494,7 +497,7 @@ def get_matching_tags():
def index(page): def index(page):
entries, random, pagination = fill_indexpage(page, db.Books, True, [db.Books.timestamp.desc()]) 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, 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}) @web.route('/books/newest', defaults={'page': 1})
@ -632,8 +635,7 @@ def author(book_id, page):
app.logger.error('Goodreads website is down/inaccessible') app.logger.error('Goodreads website is down/inaccessible')
return render_title_template('author.html', entries=entries, pagination=pagination, return render_title_template('author.html', entries=entries, pagination=pagination,
title=name, author=author_info, other_books=other_books, page="author", title=name, author=author_info, other_books=other_books, page="author")
config_authors_max=config.config_authors_max)
@web.route("/publisher") @web.route("/publisher")
@ -720,17 +722,16 @@ def series(book_id, page):
abort(404) abort(404)
# (cast(db.Ratings.rating/2, SQLString)).label('name'))\
@web.route("/ratings") @web.route("/ratings")
@login_required_if_no_ano @login_required_if_no_ano
def ratings_list(): def ratings_list():
if current_user.check_visibility(ub.SIDEBAR_RATING): if current_user.check_visibility(ub.SIDEBAR_RATING):
entries = db.session.query(db.Series, func.count('books_series_link.book').label('count'))\ entries = db.session.query(db.Ratings, func.count('books_ratings_link.book').label('count'),
.join(db.books_series_link).join(db.Books).filter(common_filters())\ (db.Ratings.rating/2).label('name'))\
.group_by(text('books_series_link.series')).order_by(db.Series.sort).all() .join(db.books_ratings_link).join(db.Books).filter(common_filters())\
charlist = db.session.query(func.upper(func.substr(db.Series.sort,1,1)).label('char')) \ .group_by(text('books_ratings_link.rating')).order_by(db.Ratings.rating).all()
.join(db.books_series_link).join(db.Books).filter(common_filters()) \ return render_title_template('list.html', entries=entries, folder='web.ratings', charlist=list(),
.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,
title=_(u"Ratings list"), page="ratingslist") title=_(u"Ratings list"), page="ratingslist")
else: else:
abort(404) abort(404)
@ -740,12 +741,12 @@ def ratings_list():
@web.route("/ratings/<int:book_id>/<int:page>") @web.route("/ratings/<int:book_id>/<int:page>")
@login_required_if_no_ano @login_required_if_no_ano
def ratings(book_id, page): def ratings(book_id, page):
name = db.session.query(db.Series).filter(db.Series.id == book_id).first() if book_id <=5:
if name: name = db.session.query(db.Ratings).filter(db.Ratings.id == book_id).first()
entries, random, pagination = fill_indexpage(page, db.Books, db.Books.series.any(db.Series.id == book_id), entries, random, pagination = fill_indexpage(page, db.Books, db.Books.ratings.any(db.Ratings.id == book_id),
[db.Books.series_index]) [db.Books.timestamp.desc()])
return render_title_template('index.html', random=random, pagination=pagination, entries=entries, return render_title_template('index.html', random=random, pagination=pagination, entries=entries,
title=_(u"Ratings: %(serie)s", serie=name.name), page="ratings") title=_(u"Ratings: %(rating)s stars", rating=(name.rating/2)), page="ratings")
else: else:
abort(404) abort(404)

Loading…
Cancel
Save