From 2929d95b264b27986a10262c07df453442dd030d Mon Sep 17 00:00:00 2001 From: OzzieIsaacs Date: Sat, 8 Jul 2017 13:50:21 +0200 Subject: [PATCH] Display all authors names in shelf, like on all other pages (#202) --- cps/templates/shelf.html | 11 ++++++++--- cps/web.py | 10 +++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cps/templates/shelf.html b/cps/templates/shelf.html index a8c52ce8..a81538e1 100644 --- a/cps/templates/shelf.html +++ b/cps/templates/shelf.html @@ -22,9 +22,14 @@

{{entry.title|shortentitle}}

- {% if entry.authors|length > 0 %} -

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

- {% endif %} +

+ {% for author in entry.authors %} + {{author.name}} + {% if not loop.last %} + & + {% endif %} + {% endfor %} +

{% if entry.ratings.__len__() > 0 %}
{% for number in range((entry.ratings[0].rating/2)|int(2)) %} diff --git a/cps/web.py b/cps/web.py index 6be3c448..935f6df3 100755 --- a/cps/web.py +++ b/cps/web.py @@ -1979,15 +1979,19 @@ def show_shelf(shelf_id): ub.and_(ub.Shelf.is_public == 1, ub.Shelf.id == shelf_id))).first() result = list() + # user is allowed to access shelf if shelf: books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id).order_by( ub.BookShelf.order.asc()).all() for book in books_in_shelf: cur_book = db.session.query(db.Books).filter(db.Books.id == book.book_id).first() result.append(cur_book) - - return render_title_template('shelf.html', entries=result, title=_(u"Shelf: '%(name)s'", name=shelf.name), + return render_title_template('shelf.html', entries=result, title=_(u"Shelf: '%(name)s'", name=shelf.name), shelf=shelf) + else: + flash(_(u"Error opening shelf. Shelf does not exist or file is not accessible"), category="error") + return redirect(url_for("index")) + @app.route("/shelf/order/", methods=["GET", "POST"]) @@ -2673,7 +2677,7 @@ def edit_book(book_id): return render_title_template('book_edit.html', book=book, authors=author_names, cc=cc, title=_(u"edit metadata")) else: - flash(_(u"Error opening eBook. File does not exist or file is not accessible:"), category="error") + flash(_(u"Error opening eBook. File does not exist or file is not accessible"), category="error") return redirect(url_for("index"))