mirror of
https://github.com/janeczku/calibre-web
synced 2024-10-31 23:26:20 +00:00
Fixes from tests
This commit is contained in:
parent
fa95d064ff
commit
d5ed5cd665
8
cps.py
8
cps.py
@ -41,6 +41,7 @@ from cps.shelf import shelf
|
|||||||
from cps.admin import admi
|
from cps.admin import admi
|
||||||
from cps.gdrive import gdrive
|
from cps.gdrive import gdrive
|
||||||
from cps.editbooks import editbook
|
from cps.editbooks import editbook
|
||||||
|
from cps.error_handler import init_errorhandler
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from cps.kobo import kobo, get_kobo_activated
|
from cps.kobo import kobo, get_kobo_activated
|
||||||
@ -58,14 +59,17 @@ except ImportError:
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
app = create_app()
|
app = create_app()
|
||||||
|
|
||||||
|
init_errorhandler()
|
||||||
|
|
||||||
app.register_blueprint(web)
|
app.register_blueprint(web)
|
||||||
app.register_blueprint(opds)
|
app.register_blueprint(opds)
|
||||||
app.register_blueprint(jinjia)
|
app.register_blueprint(jinjia)
|
||||||
app.register_blueprint(about)
|
app.register_blueprint(about)
|
||||||
app.register_blueprint(shelf)
|
app.register_blueprint(shelf)
|
||||||
app.register_blueprint(admi)
|
app.register_blueprint(admi)
|
||||||
if config.config_use_google_drive:
|
# if config.config_use_google_drive:
|
||||||
app.register_blueprint(gdrive)
|
app.register_blueprint(gdrive)
|
||||||
app.register_blueprint(editbook)
|
app.register_blueprint(editbook)
|
||||||
if kobo_available:
|
if kobo_available:
|
||||||
app.register_blueprint(kobo)
|
app.register_blueprint(kobo)
|
||||||
|
@ -1327,7 +1327,7 @@ def import_ldap_users():
|
|||||||
try:
|
try:
|
||||||
new_users = services.ldap.get_group_members(config.config_ldap_group_name)
|
new_users = services.ldap.get_group_members(config.config_ldap_group_name)
|
||||||
except (services.ldap.LDAPException, TypeError, AttributeError, KeyError) as e:
|
except (services.ldap.LDAPException, TypeError, AttributeError, KeyError) as e:
|
||||||
log.exception(e)
|
log.debug_or_exception(e)
|
||||||
showtext['text'] = _(u'Error: %(ldaperror)s', ldaperror=e)
|
showtext['text'] = _(u'Error: %(ldaperror)s', ldaperror=e)
|
||||||
return json.dumps(showtext)
|
return json.dumps(showtext)
|
||||||
if not new_users:
|
if not new_users:
|
||||||
@ -1355,7 +1355,7 @@ def import_ldap_users():
|
|||||||
try:
|
try:
|
||||||
user_data = services.ldap.get_object_details(user=user_identifier, query_filter=query_filter)
|
user_data = services.ldap.get_object_details(user=user_identifier, query_filter=query_filter)
|
||||||
except AttributeError as e:
|
except AttributeError as e:
|
||||||
log.exception(e)
|
log.debug_or_exception(e)
|
||||||
continue
|
continue
|
||||||
if user_data:
|
if user_data:
|
||||||
user_login_field = extract_dynamic_field_from_filter(user, config.config_ldap_user_object)
|
user_login_field = extract_dynamic_field_from_filter(user, config.config_ldap_user_object)
|
||||||
|
@ -48,20 +48,21 @@ def internal_error(error):
|
|||||||
instance=config.config_calibre_web_title
|
instance=config.config_calibre_web_title
|
||||||
), 500
|
), 500
|
||||||
|
|
||||||
# http error handling
|
def init_errorhandler():
|
||||||
for ex in default_exceptions:
|
# http error handling
|
||||||
if ex < 500:
|
for ex in default_exceptions:
|
||||||
app.register_error_handler(ex, error_http)
|
if ex < 500:
|
||||||
elif ex == 500:
|
app.register_error_handler(ex, error_http)
|
||||||
app.register_error_handler(ex, internal_error)
|
elif ex == 500:
|
||||||
|
app.register_error_handler(ex, internal_error)
|
||||||
|
|
||||||
|
|
||||||
if services.ldap:
|
if services.ldap:
|
||||||
# Only way of catching the LDAPException upon logging in with LDAP server down
|
# Only way of catching the LDAPException upon logging in with LDAP server down
|
||||||
@app.errorhandler(services.ldap.LDAPException)
|
@app.errorhandler(services.ldap.LDAPException)
|
||||||
def handle_exception(e):
|
def handle_exception(e):
|
||||||
log.debug('LDAP server not accessible while trying to login to opds feed')
|
log.debug('LDAP server not accessible while trying to login to opds feed')
|
||||||
return error_http(FailedDependency())
|
return error_http(FailedDependency())
|
||||||
|
|
||||||
|
|
||||||
# @app.errorhandler(InvalidRequestError)
|
# @app.errorhandler(InvalidRequestError)
|
||||||
|
@ -28,7 +28,7 @@ from functools import wraps
|
|||||||
from flask import Blueprint, request, render_template, Response, g, make_response, abort
|
from flask import Blueprint, request, render_template, Response, g, make_response, abort
|
||||||
from flask_login import current_user
|
from flask_login import current_user
|
||||||
from sqlalchemy.sql.expression import func, text, or_, and_
|
from sqlalchemy.sql.expression import func, text, or_, and_
|
||||||
|
from werkzeug.security import check_password_hash
|
||||||
|
|
||||||
from . import constants, logger, config, db, calibre_db, ub, services, get_locale, isoLanguages
|
from . import constants, logger, config, db, calibre_db, ub, services, get_locale, isoLanguages
|
||||||
from .helper import get_download_link, get_book_cover
|
from .helper import get_download_link, get_book_cover
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="btn btn-default emailconfig"><a id="basic_config" href="{{url_for('admin.configuration')}}">{{_('Edit Basic Configuration')}}</a></div>
|
<div class="btn btn-default emailconfig" id="admin_edit_email"><a href="{{url_for('admin.edit_mailsettings')}}">{{_('Edit E-mail Server Settings')}}</a></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user