|
|
@ -43,6 +43,7 @@ import re
|
|
|
|
import db
|
|
|
|
import db
|
|
|
|
from shutil import move, copyfile
|
|
|
|
from shutil import move, copyfile
|
|
|
|
from tornado.ioloop import IOLoop
|
|
|
|
from tornado.ioloop import IOLoop
|
|
|
|
|
|
|
|
import shutil
|
|
|
|
import StringIO
|
|
|
|
import StringIO
|
|
|
|
from shutil import move
|
|
|
|
from shutil import move
|
|
|
|
import gdriveutils
|
|
|
|
import gdriveutils
|
|
|
@ -198,6 +199,9 @@ lm.anonymous_user = ub.Anonymous
|
|
|
|
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
|
|
|
|
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
|
|
|
|
db.setup_db()
|
|
|
|
db.setup_db()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_gdrive_ready():
|
|
|
|
|
|
|
|
return os.path.exists('settings.yaml') and os.path.exists('gdrive_credentials')
|
|
|
|
|
|
|
|
|
|
|
|
@babel.localeselector
|
|
|
|
@babel.localeselector
|
|
|
|
def get_locale():
|
|
|
|
def get_locale():
|
|
|
|
# if a user is logged in, use the locale from the user settings
|
|
|
|
# if a user is logged in, use the locale from the user settings
|
|
|
@ -1889,17 +1893,14 @@ def configuration_helper(origin):
|
|
|
|
if content.config_google_drive_client_id != to_save["config_google_drive_client_id"]:
|
|
|
|
if content.config_google_drive_client_id != to_save["config_google_drive_client_id"]:
|
|
|
|
content.config_google_drive_client_id = to_save["config_google_drive_client_id"]
|
|
|
|
content.config_google_drive_client_id = to_save["config_google_drive_client_id"]
|
|
|
|
create_new_yaml=True
|
|
|
|
create_new_yaml=True
|
|
|
|
db_change = True
|
|
|
|
|
|
|
|
if "config_google_drive_client_secret" in to_save:
|
|
|
|
if "config_google_drive_client_secret" in to_save:
|
|
|
|
if content.config_google_drive_client_secret != to_save["config_google_drive_client_secret"]:
|
|
|
|
if content.config_google_drive_client_secret != to_save["config_google_drive_client_secret"]:
|
|
|
|
content.config_google_drive_client_secret = to_save["config_google_drive_client_secret"]
|
|
|
|
content.config_google_drive_client_secret = to_save["config_google_drive_client_secret"]
|
|
|
|
create_new_yaml=True
|
|
|
|
create_new_yaml=True
|
|
|
|
db_change = True
|
|
|
|
|
|
|
|
if "config_google_drive_calibre_url_base" in to_save:
|
|
|
|
if "config_google_drive_calibre_url_base" in to_save:
|
|
|
|
if content.config_google_drive_calibre_url_base != to_save["config_google_drive_calibre_url_base"]:
|
|
|
|
if content.config_google_drive_calibre_url_base != to_save["config_google_drive_calibre_url_base"]:
|
|
|
|
content.config_google_drive_calibre_url_base = to_save["config_google_drive_calibre_url_base"]
|
|
|
|
content.config_google_drive_calibre_url_base = to_save["config_google_drive_calibre_url_base"]
|
|
|
|
create_new_yaml=True
|
|
|
|
create_new_yaml=True
|
|
|
|
db_change = True
|
|
|
|
|
|
|
|
if ("config_use_google_drive" in to_save and not content.config_use_google_drive) or ("config_use_google_drive" not in to_save and content.config_use_google_drive):
|
|
|
|
if ("config_use_google_drive" in to_save and not content.config_use_google_drive) or ("config_use_google_drive" not in to_save and content.config_use_google_drive):
|
|
|
|
content.config_use_google_drive = "config_use_google_drive" in to_save
|
|
|
|
content.config_use_google_drive = "config_use_google_drive" in to_save
|
|
|
|
db_change = True
|
|
|
|
db_change = True
|
|
|
@ -1953,6 +1954,8 @@ def configuration_helper(origin):
|
|
|
|
if "passwd_role" in to_save:
|
|
|
|
if "passwd_role" in to_save:
|
|
|
|
content.config_default_role = content.config_default_role + ub.ROLE_PASSWD
|
|
|
|
content.config_default_role = content.config_default_role + ub.ROLE_PASSWD
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
if content.config_use_google_drive and is_gdrive_ready() and not os.path.exists(config.config_calibre_dir + "/metadata.db"):
|
|
|
|
|
|
|
|
gdriveutils.downloadFile(Gdrive.Instance().drive, None, "metadata.db", config.config_calibre_dir + "/metadata.db")
|
|
|
|
if db_change:
|
|
|
|
if db_change:
|
|
|
|
if config.db_configured:
|
|
|
|
if config.db_configured:
|
|
|
|
db.session.close()
|
|
|
|
db.session.close()
|
|
|
@ -1984,7 +1987,7 @@ def configuration_helper(origin):
|
|
|
|
if origin:
|
|
|
|
if origin:
|
|
|
|
success = True
|
|
|
|
success = True
|
|
|
|
return render_title_template("config_edit.html", origin=origin, success=success, content=config,
|
|
|
|
return render_title_template("config_edit.html", origin=origin, success=success, content=config,
|
|
|
|
show_authenticate_google_drive=not os.path.exists('settings.yaml') or not os.path.exists('gdrive_credentials'),
|
|
|
|
show_authenticate_google_drive=not is_gdrive_ready(),
|
|
|
|
title=_(u"Basic Configuration"))
|
|
|
|
title=_(u"Basic Configuration"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|