diff --git a/cps/admin.py b/cps/admin.py index fa5b1caf..55a11c3e 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -964,7 +964,8 @@ def get_updater_status(): "8": _(u'Update failed:') + u' ' + _(u'HTTP Error'), "9": _(u'Update failed:') + u' ' + _(u'Connection error'), "10": _(u'Update failed:') + u' ' + _(u'Timeout while establishing connection'), - "11": _(u'Update failed:') + u' ' + _(u'General error') + "11": _(u'Update failed:') + u' ' + _(u'General error'), + "12": _(u'Update failed:') + u' ' + _(u'Update File Could Not be Saved in Temp Dir') } status['text'] = text updater_thread.status = 0 diff --git a/cps/opds.py b/cps/opds.py index f76d5dc0..5cfb5348 100644 --- a/cps/opds.py +++ b/cps/opds.py @@ -253,6 +253,7 @@ def feed_ratings(book_id): return render_xml_template('feed.xml', entries=entries, pagination=pagination) + @opds.route("/opds/formats") @requires_basic_auth_if_no_ano def feed_formatindex(): @@ -276,6 +277,7 @@ def feed_format(book_id): db.Books, db.Books.data.any(db.Data.format == book_id.upper()), [db.Books.timestamp.desc()]) return render_xml_template('feed.xml', entries=entries, pagination=pagination) + @opds.route("/opds/language") @opds.route("/opds/language/") @requires_basic_auth_if_no_ano @@ -308,17 +310,12 @@ def feed_languages(book_id): return render_xml_template('feed.xml', entries=entries, pagination=pagination) -@opds.route("/opds/shelfindex", defaults={'public': 0}) -@opds.route("/opds/shelfindex/") +@opds.route("/opds/shelfindex") @requires_basic_auth_if_no_ano -def feed_shelfindex(public): +def feed_shelfindex(): off = request.args.get("offset") or 0 - if public != 0: - shelf = g.public_shelfes - number = len(shelf) - else: - shelf = g.user.shelf - number = shelf.count() + shelf = g.shelves_access + number = len(shelf) pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, number) return render_xml_template('feed.xml', listelements=shelf, folder='opds.feed_shelf', pagination=pagination) @@ -343,9 +340,9 @@ def feed_shelf(book_id): 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) - pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, - len(result)) - return render_xml_template('feed.xml', entries=result, pagination=pagination) + pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page, + len(result)) + return render_xml_template('feed.xml', entries=result, pagination=pagination) @opds.route("/opds/download///") diff --git a/cps/server.py b/cps/server.py index a59d7a38..a108181b 100755 --- a/cps/server.py +++ b/cps/server.py @@ -24,7 +24,7 @@ import signal import socket try: - from gevent.pyewsgi import WSGIServer + from gevent.pywsgi import WSGIServer from gevent.pool import Pool from gevent import __version__ as _version VERSION = 'Gevent ' + _version @@ -171,6 +171,7 @@ class WebServer(object): except Exception as ex: log.error("Error starting server: %s", ex) print("Error starting server: %s" % ex) + self.stop() return False finally: self.wsgiserver = None diff --git a/cps/shelf.py b/cps/shelf.py index afee1eaa..c78059ca 100644 --- a/cps/shelf.py +++ b/cps/shelf.py @@ -204,21 +204,34 @@ def create_shelf(): shelf.is_public = 1 shelf.name = to_save["title"] shelf.user_id = int(current_user.id) - existing_shelf = ub.session.query(ub.Shelf).filter( - or_((ub.Shelf.name == to_save["title"]) & (ub.Shelf.is_public == 1), - (ub.Shelf.name == to_save["title"]) & (ub.Shelf.user_id == int(current_user.id)))).first() - if existing_shelf: - flash(_(u"A shelf with the name '%(title)s' already exists.", title=to_save["title"]), category="error") + + is_shelf_name_unique = False + if shelf.is_public == 1: + is_shelf_name_unique = ub.session.query(ub.Shelf) \ + .filter((ub.Shelf.name == to_save["title"]) & (ub.Shelf.is_public == 1)) \ + .first() is None + + if not is_shelf_name_unique: + flash(_(u"A public shelf with the name '%(title)s' already exists.", title=to_save["title"]), category="error") else: + is_shelf_name_unique = ub.session.query(ub.Shelf) \ + .filter((ub.Shelf.name == to_save["title"]) & (ub.Shelf.is_public == 0) & (ub.Shelf.user_id == int(current_user.id))) \ + .first() is None + + if not is_shelf_name_unique: + flash(_(u"A private shelf with the name '%(title)s' already exists.", title=to_save["title"]), category="error") + + if is_shelf_name_unique: try: ub.session.add(shelf) ub.session.commit() flash(_(u"Shelf %(title)s created", title=to_save["title"]), category="success") + return redirect(url_for('shelf.show_shelf', shelf_id = shelf.id )) except Exception: flash(_(u"There was an error"), category="error") - return render_title_template('shelf_edit.html', shelf=shelf, title=_(u"create a shelf"), page="shelfcreate") + return render_title_template('shelf_edit.html', shelf=shelf, title=_(u"Create a Shelf"), page="shelfcreate") else: - return render_title_template('shelf_edit.html', shelf=shelf, title=_(u"create a shelf"), page="shelfcreate") + return render_title_template('shelf_edit.html', shelf=shelf, title=_(u"Create a Shelf"), page="shelfcreate") @shelf.route("/shelf/edit/", methods=["GET", "POST"]) @@ -227,13 +240,26 @@ def edit_shelf(shelf_id): shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first() if request.method == "POST": to_save = request.form.to_dict() - existing_shelf = ub.session.query(ub.Shelf).filter( - or_((ub.Shelf.name == to_save["title"]) & (ub.Shelf.is_public == 1), - (ub.Shelf.name == to_save["title"]) & (ub.Shelf.user_id == int(current_user.id)))).filter( - ub.Shelf.id != shelf_id).first() - if existing_shelf: - flash(_(u"A shelf with the name '%(title)s' already exists.", title=to_save["title"]), category="error") + + is_shelf_name_unique = False + if shelf.is_public == 1: + is_shelf_name_unique = ub.session.query(ub.Shelf) \ + .filter((ub.Shelf.name == to_save["title"]) & (ub.Shelf.is_public == 1)) \ + .filter(ub.Shelf.id != shelf_id) \ + .first() is None + + if not is_shelf_name_unique: + flash(_(u"A public shelf with the name '%(title)s' already exists.", title=to_save["title"]), category="error") else: + is_shelf_name_unique = ub.session.query(ub.Shelf) \ + .filter((ub.Shelf.name == to_save["title"]) & (ub.Shelf.is_public == 0) & (ub.Shelf.user_id == int(current_user.id))) \ + .filter(ub.Shelf.id != shelf_id) \ + .first() is None + + if not is_shelf_name_unique: + flash(_(u"A private shelf with the name '%(title)s' already exists.", title=to_save["title"]), category="error") + + if is_shelf_name_unique: shelf.name = to_save["title"] if "is_public" in to_save: shelf.is_public = 1 diff --git a/cps/static/js/caliBlur.js b/cps/static/js/caliBlur.js index 9313ee94..267b2837 100644 --- a/cps/static/js/caliBlur.js +++ b/cps/static/js/caliBlur.js @@ -365,7 +365,7 @@ $( '#logout' ).parent().addClass( 'dropdown' ).appendTo( '.profileDropli' ); // Remove the modals except from some areas where they are needed bodyClass = $( 'body' ).attr( 'class' ).split(' '); -modalWanted = ['admin', 'editbook', 'config', 'uiconfig']; +modalWanted = ['admin', 'editbook', 'config', 'uiconfig', 'me', 'edituser']; if ( $.inArray( bodyClass[0], modalWanted) != -1 ) { } else { diff --git a/cps/templates/admin.html b/cps/templates/admin.html index 5b2ad78c..69deee09 100644 --- a/cps/templates/admin.html +++ b/cps/templates/admin.html @@ -15,7 +15,7 @@ {{_('Downloads')}} {{_('Admin')}} {{_('Download')}} - {{_('View eBooks')}} + {{_('View Books')}} {{_('Upload')}} {{_('Edit')}} @@ -58,7 +58,7 @@ {{email.mail_from}} - + diff --git a/cps/templates/detail.html b/cps/templates/detail.html index c7fce551..8522a6a3 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -225,7 +225,7 @@
{% if g.user.is_authenticated %} - {% if g.user.shelf.all() or g.public_shelfes %} + {% if g.user.shelf.all() or g.shelves_access %}