diff --git a/cps/shelf.py b/cps/shelf.py index 28ee4a3d..6300a0ce 100644 --- a/cps/shelf.py +++ b/cps/shelf.py @@ -22,7 +22,7 @@ # along with this program. If not, see . from flask import Blueprint, request, flash, redirect, url_for -from cps import ub +from cps import ub, searched_ids from flask_babel import gettext as _ from sqlalchemy.sql.expression import func, or_ from flask_login import login_required, current_user @@ -104,18 +104,18 @@ def search_to_shelf(shelf_id): flash(_(u"User is not allowed to edit public shelves"), category="error") return redirect(url_for('index')) - if current_user.id in ub.searched_ids and ub.searched_ids[current_user.id]: + if current_user.id in searched_ids and searched_ids[current_user.id]: books_for_shelf = list() books_in_shelf = ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id).all() if books_in_shelf: book_ids = list() for book_id in books_in_shelf: book_ids.append(book_id.book_id) - for id in ub.searched_ids[current_user.id]: + for id in searched_ids[current_user.id]: if id not in book_ids: books_for_shelf.append(id) else: - books_for_shelf = ub.searched_ids[current_user.id] + books_for_shelf = searched_ids[current_user.id] if not books_for_shelf: app.logger.info("Books are already part of the shelf: %s" % shelf.name) @@ -136,7 +136,7 @@ def search_to_shelf(shelf_id): flash(_(u"Books have been added to shelf: %(sname)s", sname=shelf.name), category="success") else: flash(_(u"Could not add books to shelf: %(sname)s", sname=shelf.name), category="error") - return redirect(url_for('index')) + return redirect(url_for('web.index')) @shelf.route("/shelf/remove//") @@ -259,7 +259,7 @@ def delete_shelf(shelf_id): ub.session.query(ub.BookShelf).filter(ub.BookShelf.shelf == shelf_id).delete() ub.session.commit() app.logger.info(_(u"successfully deleted shelf %(name)s", name=cur_shelf.name, category="success")) - return redirect(url_for('index')) + return redirect(url_for('web.index')) @shelf.route("/shelf/") diff --git a/cps/templates/http_error.html b/cps/templates/http_error.html index 98763cdc..36471fce 100644 --- a/cps/templates/http_error.html +++ b/cps/templates/http_error.html @@ -17,7 +17,7 @@ {% endif %} -
+

{{ error_code }}

{{ error_name }}

{{_('Back to home')}} diff --git a/cps/web.py b/cps/web.py index 0a4a6e9d..ae577e7e 100644 --- a/cps/web.py +++ b/cps/web.py @@ -23,7 +23,7 @@ from cps import mimetypes, global_WorkerThread, searched_ids from flask import render_template, request, redirect, url_for, send_from_directory, make_response, g, flash, abort -# from werkzeug.exceptions import default_exceptions +from werkzeug.exceptions import default_exceptions import helper import os # from sqlalchemy.sql.expression import func @@ -101,7 +101,7 @@ EXTENSIONS_AUDIO = {'mp3', 'm4a', 'm4b'} # EXTENSIONS_READER = set(['txt', 'pdf', 'epub', 'zip', 'cbz', 'tar', 'cbt'] + (['rar','cbr'] if rar_support else [])) -''''# custom error page +# custom error page def error_http(error): return render_template('http_error.html', error_code=error.code, @@ -115,7 +115,7 @@ for ex in default_exceptions: if ex < 500: app.register_error_handler(ex, error_http) -''' + web = Blueprint('web', __name__) @@ -967,7 +967,6 @@ def advanced_search(): db.session.connection().connection.connection.create_function("lower", 1, db.lcase) q = db.session.query(db.Books) - # postargs = request.form.to_dict() include_tag_inputs = request.args.getlist('include_tag') exclude_tag_inputs = request.args.getlist('exclude_tag')