1
0
mirror of https://github.com/janeczku/calibre-web synced 2025-12-06 16:28:06 +00:00
This commit is contained in:
Ozzieisaacs
2020-04-14 18:28:16 +02:00
parent a8b36aed92
commit 3fbaba6693
6 changed files with 31 additions and 14 deletions

View File

@@ -42,6 +42,8 @@ from .helper import speaking_language, check_valid_domain, send_test_mail, reset
from .gdriveutils import is_gdrive_ready, gdrive_support
from .web import admin_required, render_title_template, before_request, unconfigured, login_required_if_no_ano
log = logger.create()
feature_support = {
'ldap': bool(services.ldap),
'goodreads': bool(services.goodreads_support),
@@ -57,7 +59,8 @@ feature_support = {
try:
from .oauth_bb import oauth_check, oauthblueprints
feature_support['oauth'] = True
except ImportError:
except ImportError as err:
log.debug('Cannot import Flask-Dance, login with Oauth will not work: %s', err)
feature_support['oauth'] = False
oauthblueprints = []
oauth_check = {}
@@ -65,7 +68,7 @@ except ImportError:
feature_support['gdrive'] = gdrive_support
admi = Blueprint('admin', __name__)
log = logger.create()
@admi.route("/admin")

View File

@@ -23,7 +23,16 @@ from flask import session
try:
from flask_dance.consumer.backend.sqla import SQLAlchemyBackend, first, _get_real_user
from sqlalchemy.orm.exc import NoResultFound
except ImportError:
# fails on flask-dance >1.3, due to renaming
try:
from flask_dance.consumer.storage.sqla import SQLAlchemyStorage as SQLAlchemyBackend
from flask_dance.consumer.storage.sqla import first, _get_real_user
from sqlalchemy.orm.exc import NoResultFound
except ImportError:
pass
try:
class OAuthBackend(SQLAlchemyBackend):
"""
Stores and retrieves OAuth tokens using a relational database through
@@ -152,5 +161,5 @@ try:
blueprint=blueprint, user=user, user_id=user_id,
))
except ImportError:
except Exception:
pass

View File

@@ -26,7 +26,7 @@ log = logger.create()
try: from . import goodreads_support
except ImportError as err:
log.debug("cannot import goodreads, showing authors-metadata will not work: %s", err)
log.debug("Cannot import goodreads, showing authors-metadata will not work: %s", err)
goodreads_support = None
@@ -34,7 +34,7 @@ try:
from . import simpleldap as ldap
from .simpleldap import ldapVersion
except ImportError as err:
log.debug("cannot import simpleldap, logging in with ldap will not work: %s", err)
log.debug("Cannot import simpleldap, logging in with ldap will not work: %s", err)
ldap = None
ldapVersion = None
@@ -42,6 +42,6 @@ try:
from . import SyncToken as SyncToken
kobo = True
except ImportError as err:
log.debug("cannot import SyncToken, syncing books with Kobo Devices will not work: %s", err)
log.debug("Cannot import SyncToken, syncing books with Kobo Devices will not work: %s", err)
kobo = None
SyncToken = None

View File

@@ -30,7 +30,12 @@ try:
from flask_dance.consumer.backend.sqla import OAuthConsumerMixin
oauth_support = True
except ImportError:
oauth_support = False
# fails on flask-dance >1.3, due to renaming
try:
from flask_dance.consumer.storage.sqla import OAuthConsumerMixin
oauth_support = True
except ImportError:
oauth_support = False
from sqlalchemy import create_engine, exc, exists
from sqlalchemy import Column, ForeignKey
from sqlalchemy import String, Integer, SmallInteger, Boolean, DateTime