Fix feature support
This commit is contained in:
parent
e411c0fded
commit
8bfcdffeb6
|
@ -68,6 +68,7 @@ config = config_sql.load_configuration(ub.session)
|
||||||
from . import db, services
|
from . import db, services
|
||||||
|
|
||||||
searched_ids = {}
|
searched_ids = {}
|
||||||
|
feature_support = []
|
||||||
|
|
||||||
from .worker import WorkerThread
|
from .worker import WorkerThread
|
||||||
global_WorkerThread = WorkerThread()
|
global_WorkerThread = WorkerThread()
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
from __future__ import division, print_function, unicode_literals
|
from __future__ import division, print_function, unicode_literals
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
from sqlalchemy import exc, Column, String, Integer, SmallInteger, Boolean
|
from sqlalchemy import exc, Column, String, Integer, SmallInteger, Boolean
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
@ -43,41 +44,52 @@ class _Settings(_Base):
|
||||||
mail_login = Column(String, default='mail@example.com')
|
mail_login = Column(String, default='mail@example.com')
|
||||||
mail_password = Column(String, default='mypassword')
|
mail_password = Column(String, default='mypassword')
|
||||||
mail_from = Column(String, default='automailer <mail@example.com>')
|
mail_from = Column(String, default='automailer <mail@example.com>')
|
||||||
|
|
||||||
config_calibre_dir = Column(String)
|
config_calibre_dir = Column(String)
|
||||||
config_port = Column(Integer, default=constants.DEFAULT_PORT)
|
config_port = Column(Integer, default=constants.DEFAULT_PORT)
|
||||||
config_certfile = Column(String)
|
config_certfile = Column(String)
|
||||||
config_keyfile = Column(String)
|
config_keyfile = Column(String)
|
||||||
|
|
||||||
config_calibre_web_title = Column(String, default=u'Calibre-Web')
|
config_calibre_web_title = Column(String, default=u'Calibre-Web')
|
||||||
config_books_per_page = Column(Integer, default=60)
|
config_books_per_page = Column(Integer, default=60)
|
||||||
config_random_books = Column(Integer, default=4)
|
config_random_books = Column(Integer, default=4)
|
||||||
config_authors_max = Column(Integer, default=0)
|
config_authors_max = Column(Integer, default=0)
|
||||||
config_read_column = Column(Integer, default=0)
|
config_read_column = Column(Integer, default=0)
|
||||||
config_title_regex = Column(String, default=u'^(A|The|An|Der|Die|Das|Den|Ein|Eine|Einen|Dem|Des|Einem|Eines)\s+')
|
config_title_regex = Column(String, default=u'^(A|The|An|Der|Die|Das|Den|Ein|Eine|Einen|Dem|Des|Einem|Eines)\s+')
|
||||||
|
config_mature_content_tags = Column(String, default='')
|
||||||
|
config_theme = Column(Integer, default=0)
|
||||||
|
|
||||||
config_log_level = Column(SmallInteger, default=logger.DEFAULT_LOG_LEVEL)
|
config_log_level = Column(SmallInteger, default=logger.DEFAULT_LOG_LEVEL)
|
||||||
|
config_logfile = Column(String)
|
||||||
config_access_log = Column(SmallInteger, default=0)
|
config_access_log = Column(SmallInteger, default=0)
|
||||||
|
config_access_logfile = Column(String)
|
||||||
|
|
||||||
config_uploading = Column(SmallInteger, default=0)
|
config_uploading = Column(SmallInteger, default=0)
|
||||||
config_anonbrowse = Column(SmallInteger, default=0)
|
config_anonbrowse = Column(SmallInteger, default=0)
|
||||||
config_public_reg = Column(SmallInteger, default=0)
|
config_public_reg = Column(SmallInteger, default=0)
|
||||||
|
config_remote_login = Column(Boolean, default=False)
|
||||||
|
|
||||||
|
|
||||||
config_default_role = Column(SmallInteger, default=0)
|
config_default_role = Column(SmallInteger, default=0)
|
||||||
config_default_show = Column(SmallInteger, default=6143)
|
config_default_show = Column(SmallInteger, default=6143)
|
||||||
config_columns_to_ignore = Column(String)
|
config_columns_to_ignore = Column(String)
|
||||||
|
|
||||||
config_use_google_drive = Column(Boolean, default=False)
|
config_use_google_drive = Column(Boolean, default=False)
|
||||||
config_google_drive_folder = Column(String)
|
config_google_drive_folder = Column(String)
|
||||||
config_google_drive_watch_changes_response = Column(String)
|
config_google_drive_watch_changes_response = Column(String)
|
||||||
config_remote_login = Column(Boolean, default=False)
|
|
||||||
config_use_goodreads = Column(Boolean, default=False)
|
config_use_goodreads = Column(Boolean, default=False)
|
||||||
config_goodreads_api_key = Column(String)
|
config_goodreads_api_key = Column(String)
|
||||||
config_goodreads_api_secret = Column(String)
|
config_goodreads_api_secret = Column(String)
|
||||||
|
|
||||||
config_login_type = Column(Integer, default=0)
|
config_login_type = Column(Integer, default=0)
|
||||||
# config_use_ldap = Column(Boolean)
|
|
||||||
config_ldap_provider_url = Column(String)
|
config_oauth_provider = Column(Boolean)
|
||||||
config_ldap_dn = Column(String)
|
|
||||||
# config_use_github_oauth = Column(Boolean)
|
|
||||||
config_github_oauth_client_id = Column(String)
|
config_github_oauth_client_id = Column(String)
|
||||||
config_github_oauth_client_secret = Column(String)
|
config_github_oauth_client_secret = Column(String)
|
||||||
# config_use_google_oauth = Column(Boolean)
|
|
||||||
config_google_oauth_client_id = Column(String)
|
config_google_oauth_client_id = Column(String)
|
||||||
config_google_oauth_client_secret = Column(String)
|
config_google_oauth_client_secret = Column(String)
|
||||||
|
|
||||||
config_ldap_provider_url = Column(String, default='localhost')
|
config_ldap_provider_url = Column(String, default='localhost')
|
||||||
config_ldap_port = Column(SmallInteger, default=389)
|
config_ldap_port = Column(SmallInteger, default=389)
|
||||||
config_ldap_schema = Column(String, default='ldap')
|
config_ldap_schema = Column(String, default='ldap')
|
||||||
|
@ -90,14 +102,12 @@ class _Settings(_Base):
|
||||||
config_ldap_dn = Column(String)
|
config_ldap_dn = Column(String)
|
||||||
config_ldap_user_object = Column(String)
|
config_ldap_user_object = Column(String)
|
||||||
config_ldap_openldap = Column(Boolean, default=False)
|
config_ldap_openldap = Column(Boolean, default=False)
|
||||||
config_mature_content_tags = Column(String, default='')
|
|
||||||
config_logfile = Column(String)
|
|
||||||
config_access_logfile = Column(String)
|
|
||||||
config_ebookconverter = Column(Integer, default=0)
|
config_ebookconverter = Column(Integer, default=0)
|
||||||
config_converterpath = Column(String)
|
config_converterpath = Column(String)
|
||||||
config_calibre = Column(String)
|
config_calibre = Column(String)
|
||||||
config_rarfile_location = Column(String)
|
config_rarfile_location = Column(String)
|
||||||
config_theme = Column(Integer, default=0)
|
|
||||||
config_updatechannel = Column(Integer, default=constants.UPDATE_STABLE)
|
config_updatechannel = Column(Integer, default=constants.UPDATE_STABLE)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@ -270,6 +280,17 @@ def _migrate_table(session, orm_class):
|
||||||
if changed:
|
if changed:
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
|
def autodetect_calibre_binary():
|
||||||
|
if sys.platform == "win32":
|
||||||
|
calibre_path = ["C:\\program files\calibre\calibre-convert.exe",
|
||||||
|
"C:\\program files(x86)\calibre\calibre-convert.exe"]
|
||||||
|
else:
|
||||||
|
calibre_path = ["/opt/calibre/ebook-convert"]
|
||||||
|
for element in calibre_path:
|
||||||
|
if os.path.isfile(element) and os.access(element, os.X_OK):
|
||||||
|
return element
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def _migrate_database(session):
|
def _migrate_database(session):
|
||||||
# make sure the table is created, if it does not exist
|
# make sure the table is created, if it does not exist
|
||||||
|
|
|
@ -34,9 +34,11 @@ try:
|
||||||
from pydrive.drive import GoogleDrive
|
from pydrive.drive import GoogleDrive
|
||||||
from pydrive.auth import RefreshError
|
from pydrive.auth import RefreshError
|
||||||
from apiclient import errors
|
from apiclient import errors
|
||||||
gdrive_support = True
|
feature_support['gdrive'] = True
|
||||||
|
# gdrive_support = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
gdrive_support = False
|
feature_support['gdrive'] = True
|
||||||
|
#gdrive_support = False
|
||||||
|
|
||||||
from . import logger, cli, config
|
from . import logger, cli, config
|
||||||
from .constants import CONFIG_DIR as _CONFIG_DIR
|
from .constants import CONFIG_DIR as _CONFIG_DIR
|
||||||
|
@ -574,7 +576,7 @@ def update_settings(client_id, client_secret, redirect_uri):
|
||||||
|
|
||||||
|
|
||||||
def get_error_text(client_secrets=None):
|
def get_error_text(client_secrets=None):
|
||||||
if not gdrive_support:
|
if not feature_support['gdrive']:
|
||||||
return 'Import of optional Google Drive requirements missing'
|
return 'Import of optional Google Drive requirements missing'
|
||||||
|
|
||||||
if not os.path.isfile(CLIENT_SECRETS):
|
if not os.path.isfile(CLIENT_SECRETS):
|
||||||
|
|
|
@ -50,8 +50,6 @@ def init_app(app, config):
|
||||||
app.config['LDAP_USE_TLS'] = bool(config.config_ldap_use_tls)
|
app.config['LDAP_USE_TLS'] = bool(config.config_ldap_use_tls)
|
||||||
app.config['LDAP_OPENLDAP'] = bool(config.config_ldap_openldap)
|
app.config['LDAP_OPENLDAP'] = bool(config.config_ldap_openldap)
|
||||||
|
|
||||||
# app.config['LDAP_BASE_DN'] = 'ou=users,dc=yunohost,dc=org'
|
|
||||||
# app.config['LDAP_USER_OBJECT_FILTER'] = '(uid=%s)'
|
|
||||||
_ldap.init_app(app)
|
_ldap.init_app(app)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
<label for="config_calibre_dir">{{_('Location of Calibre database')}}</label>
|
<label for="config_calibre_dir">{{_('Location of Calibre database')}}</label>
|
||||||
<input type="text" class="form-control" name="config_calibre_dir" id="config_calibre_dir" value="{% if config.config_calibre_dir != None %}{{ config.config_calibre_dir }}{% endif %}" autocomplete="off">
|
<input type="text" class="form-control" name="config_calibre_dir" id="config_calibre_dir" value="{% if config.config_calibre_dir != None %}{{ config.config_calibre_dir }}{% endif %}" autocomplete="off">
|
||||||
</div>
|
</div>
|
||||||
|
{% if feature_support['gdrive'] %}
|
||||||
<div class="form-group required">
|
<div class="form-group required">
|
||||||
<input type="checkbox" id="config_use_google_drive" name="config_use_google_drive" data-control="gdrive_settings" {% if config.config_use_google_drive %}checked{% endif %} >
|
<input type="checkbox" id="config_use_google_drive" name="config_use_google_drive" data-control="gdrive_settings" {% if config.config_use_google_drive %}checked{% endif %} >
|
||||||
<label for="config_use_google_drive">{{_('Use Google Drive?')}}</label>
|
<label for="config_use_google_drive">{{_('Use Google Drive?')}}</label>
|
||||||
|
@ -66,6 +67,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,7 +18,7 @@ python-Levenshtein>=0.12.0
|
||||||
|
|
||||||
# ldap login
|
# ldap login
|
||||||
python_ldap>=3.0.0
|
python_ldap>=3.0.0
|
||||||
flask-simpleldap
|
flask-simpleldap>=1.2.0
|
||||||
|
|
||||||
# extracting metadata
|
# extracting metadata
|
||||||
lxml>=3.8.0
|
lxml>=3.8.0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user