Kobo sync enable/disable working
This commit is contained in:
parent
4ab3dc2599
commit
e44494aad0
4
cps.py
4
cps.py
|
@ -43,9 +43,9 @@ from cps.gdrive import gdrive
|
||||||
from cps.editbooks import editbook
|
from cps.editbooks import editbook
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from cps.kobo import kobo
|
from cps.kobo import kobo, get_kobo_activated
|
||||||
from cps.kobo_auth import kobo_auth
|
from cps.kobo_auth import kobo_auth
|
||||||
kobo_available = True
|
kobo_available = get_kobo_activated()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
kobo_available = False
|
kobo_available = False
|
||||||
|
|
||||||
|
|
18
cps/admin.py
18
cps/admin.py
|
@ -532,7 +532,7 @@ def _configuration_update_helper():
|
||||||
_config_checkbox_int("config_uploading")
|
_config_checkbox_int("config_uploading")
|
||||||
_config_checkbox_int("config_anonbrowse")
|
_config_checkbox_int("config_anonbrowse")
|
||||||
_config_checkbox_int("config_public_reg")
|
_config_checkbox_int("config_public_reg")
|
||||||
_config_checkbox_int("config_kobo_sync")
|
reboot_required |= _config_checkbox_int("config_kobo_sync")
|
||||||
_config_checkbox_int("config_kobo_proxy")
|
_config_checkbox_int("config_kobo_proxy")
|
||||||
|
|
||||||
|
|
||||||
|
@ -679,6 +679,7 @@ def new_user():
|
||||||
content = ub.User()
|
content = ub.User()
|
||||||
languages = speaking_language()
|
languages = speaking_language()
|
||||||
translations = [LC('en')] + babel.list_translations()
|
translations = [LC('en')] + babel.list_translations()
|
||||||
|
kobo_support = feature_support['kobo'] and config.config_kobo_sync
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
to_save = request.form.to_dict()
|
to_save = request.form.to_dict()
|
||||||
content.default_language = to_save["default_language"]
|
content.default_language = to_save["default_language"]
|
||||||
|
@ -694,7 +695,7 @@ def new_user():
|
||||||
if not to_save["nickname"] or not to_save["email"] or not to_save["password"]:
|
if not to_save["nickname"] or not to_save["email"] or not to_save["password"]:
|
||||||
flash(_(u"Please fill out all fields!"), category="error")
|
flash(_(u"Please fill out all fields!"), category="error")
|
||||||
return render_title_template("user_edit.html", new_user=1, content=content, translations=translations,
|
return render_title_template("user_edit.html", new_user=1, content=content, translations=translations,
|
||||||
registered_oauth=oauth_check, feature_support=feature_support,
|
registered_oauth=oauth_check, kobo_support=kobo_support,
|
||||||
title=_(u"Add new user"))
|
title=_(u"Add new user"))
|
||||||
content.password = generate_password_hash(to_save["password"])
|
content.password = generate_password_hash(to_save["password"])
|
||||||
existing_user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == to_save["nickname"].lower())\
|
existing_user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == to_save["nickname"].lower())\
|
||||||
|
@ -706,7 +707,7 @@ def new_user():
|
||||||
if config.config_public_reg and not check_valid_domain(to_save["email"]):
|
if config.config_public_reg and not check_valid_domain(to_save["email"]):
|
||||||
flash(_(u"E-mail is not from valid domain"), category="error")
|
flash(_(u"E-mail is not from valid domain"), category="error")
|
||||||
return render_title_template("user_edit.html", new_user=1, content=content, translations=translations,
|
return render_title_template("user_edit.html", new_user=1, content=content, translations=translations,
|
||||||
registered_oauth=oauth_check, feature_support=feature_support,
|
registered_oauth=oauth_check, kobo_support=kobo_support,
|
||||||
title=_(u"Add new user"))
|
title=_(u"Add new user"))
|
||||||
else:
|
else:
|
||||||
content.email = to_save["email"]
|
content.email = to_save["email"]
|
||||||
|
@ -714,7 +715,7 @@ def new_user():
|
||||||
flash(_(u"Found an existing account for this e-mail address or nickname."), category="error")
|
flash(_(u"Found an existing account for this e-mail address or nickname."), category="error")
|
||||||
return render_title_template("user_edit.html", new_user=1, content=content, translations=translations,
|
return render_title_template("user_edit.html", new_user=1, content=content, translations=translations,
|
||||||
languages=languages, title=_(u"Add new user"), page="newuser",
|
languages=languages, title=_(u"Add new user"), page="newuser",
|
||||||
feature_support=feature_support, registered_oauth=oauth_check)
|
kobo_support=kobo_support, registered_oauth=oauth_check)
|
||||||
try:
|
try:
|
||||||
ub.session.add(content)
|
ub.session.add(content)
|
||||||
ub.session.commit()
|
ub.session.commit()
|
||||||
|
@ -732,7 +733,7 @@ def new_user():
|
||||||
# content.mature_content = bool(config.config_default_show & constants.MATURE_CONTENT)
|
# content.mature_content = bool(config.config_default_show & constants.MATURE_CONTENT)
|
||||||
return render_title_template("user_edit.html", new_user=1, content=content, translations=translations,
|
return render_title_template("user_edit.html", new_user=1, content=content, translations=translations,
|
||||||
languages=languages, title=_(u"Add new user"), page="newuser",
|
languages=languages, title=_(u"Add new user"), page="newuser",
|
||||||
feature_support=feature_support, registered_oauth=oauth_check)
|
kobo_support=kobo_support, registered_oauth=oauth_check)
|
||||||
|
|
||||||
|
|
||||||
@admi.route("/admin/mailsettings")
|
@admi.route("/admin/mailsettings")
|
||||||
|
@ -787,6 +788,7 @@ def edit_user(user_id):
|
||||||
downloads = list()
|
downloads = list()
|
||||||
languages = speaking_language()
|
languages = speaking_language()
|
||||||
translations = babel.list_translations() + [LC('en')]
|
translations = babel.list_translations() + [LC('en')]
|
||||||
|
kobo_support = feature_support['kobo'] and config.config_kobo_sync
|
||||||
for book in content.downloads:
|
for book in content.downloads:
|
||||||
downloadbook = db.session.query(db.Books).filter(db.Books.id == book.book_id).first()
|
downloadbook = db.session.query(db.Books).filter(db.Books.id == book.book_id).first()
|
||||||
if downloadbook:
|
if downloadbook:
|
||||||
|
@ -855,7 +857,7 @@ def edit_user(user_id):
|
||||||
translations=translations,
|
translations=translations,
|
||||||
languages=languages,
|
languages=languages,
|
||||||
mail_configured = config.get_mail_server_configured(),
|
mail_configured = config.get_mail_server_configured(),
|
||||||
feature_support=feature_support,
|
kobo_support=kobo_support,
|
||||||
new_user=0,
|
new_user=0,
|
||||||
content=content,
|
content=content,
|
||||||
downloads=downloads,
|
downloads=downloads,
|
||||||
|
@ -874,7 +876,7 @@ def edit_user(user_id):
|
||||||
new_user=0, content=content,
|
new_user=0, content=content,
|
||||||
downloads=downloads,
|
downloads=downloads,
|
||||||
registered_oauth=oauth_check,
|
registered_oauth=oauth_check,
|
||||||
feature_support=feature_support,
|
kobo_support=kobo_support,
|
||||||
title=_(u"Edit User %(nick)s", nick=content.nickname),
|
title=_(u"Edit User %(nick)s", nick=content.nickname),
|
||||||
page="edituser")
|
page="edituser")
|
||||||
|
|
||||||
|
@ -894,7 +896,7 @@ def edit_user(user_id):
|
||||||
downloads=downloads,
|
downloads=downloads,
|
||||||
registered_oauth=oauth_check,
|
registered_oauth=oauth_check,
|
||||||
mail_configured=config.get_mail_server_configured(),
|
mail_configured=config.get_mail_server_configured(),
|
||||||
feature_support=feature_support,
|
kobo_support=kobo_support,
|
||||||
title=_(u"Edit User %(nick)s", nick=content.nickname), page="edituser")
|
title=_(u"Edit User %(nick)s", nick=content.nickname), page="edituser")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,8 @@ CONNECTION_SPECIFIC_HEADERS = [
|
||||||
"transfer-encoding",
|
"transfer-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_kobo_activated():
|
||||||
|
return config.config_kobo_sync
|
||||||
|
|
||||||
def redirect_or_proxy_request():
|
def redirect_or_proxy_request():
|
||||||
if config.config_kobo_proxy:
|
if config.config_kobo_proxy:
|
||||||
|
|
|
@ -41,3 +41,4 @@ try:
|
||||||
except ImportError as err:
|
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
|
kobo = None
|
||||||
|
SyncToken = None
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if feature_support['kobo'] and not new_user %}
|
{% if kobo_support and not new_user %}
|
||||||
<label>{{ _('Kobo Sync Token')}}</label>
|
<label>{{ _('Kobo Sync Token')}}</label>
|
||||||
<div class="form-group col">
|
<div class="form-group col">
|
||||||
<a class="btn btn-default" id="config_create_kobo_token" data-toggle="modal" data-target="#modal_kobo_token" data-remote="false" href="{{ url_for('kobo_auth.generate_auth_token', user_id=content.id) }}">{{_('Create/View')}}</a>
|
<a class="btn btn-default" id="config_create_kobo_token" data-toggle="modal" data-target="#modal_kobo_token" data-remote="false" href="{{ url_for('kobo_auth.generate_auth_token', user_id=content.id) }}">{{_('Create/View')}}</a>
|
||||||
|
|
12
cps/web.py
12
cps/web.py
|
@ -43,7 +43,7 @@ from werkzeug.exceptions import default_exceptions
|
||||||
from werkzeug.datastructures import Headers
|
from werkzeug.datastructures import Headers
|
||||||
from werkzeug.security import generate_password_hash, check_password_hash
|
from werkzeug.security import generate_password_hash, check_password_hash
|
||||||
|
|
||||||
from . import constants, config, logger, isoLanguages, services, worker
|
from . import constants, logger, isoLanguages, services, worker
|
||||||
from . import searched_ids, lm, babel, db, ub, config, get_locale, app
|
from . import searched_ids, lm, babel, db, ub, config, get_locale, app
|
||||||
from .gdriveutils import getFileFromEbooksFolder, do_gdrive_download
|
from .gdriveutils import getFileFromEbooksFolder, do_gdrive_download
|
||||||
from .helper import common_filters, get_search_results, fill_indexpage, speaking_language, check_valid_domain, \
|
from .helper import common_filters, get_search_results, fill_indexpage, speaking_language, check_valid_domain, \
|
||||||
|
@ -1287,10 +1287,12 @@ def profile():
|
||||||
downloads = list()
|
downloads = list()
|
||||||
languages = speaking_language()
|
languages = speaking_language()
|
||||||
translations = babel.list_translations() + [LC('en')]
|
translations = babel.list_translations() + [LC('en')]
|
||||||
|
kobo_support = feature_support['kobo'] and config.config_kobo_sync
|
||||||
if feature_support['oauth']:
|
if feature_support['oauth']:
|
||||||
oauth_status = get_oauth_status()
|
oauth_status = get_oauth_status()
|
||||||
else:
|
else:
|
||||||
oauth_status = None
|
oauth_status = None
|
||||||
|
|
||||||
for book in current_user.downloads:
|
for book in current_user.downloads:
|
||||||
downloadBook = db.session.query(db.Books).filter(db.Books.id == book.book_id).first()
|
downloadBook = db.session.query(db.Books).filter(db.Books.id == book.book_id).first()
|
||||||
if downloadBook:
|
if downloadBook:
|
||||||
|
@ -1312,7 +1314,7 @@ def profile():
|
||||||
flash(_(u"E-mail is not from valid domain"), category="error")
|
flash(_(u"E-mail is not from valid domain"), category="error")
|
||||||
return render_title_template("user_edit.html", content=current_user, downloads=downloads,
|
return render_title_template("user_edit.html", content=current_user, downloads=downloads,
|
||||||
title=_(u"%(name)s's profile", name=current_user.nickname), page="me",
|
title=_(u"%(name)s's profile", name=current_user.nickname), page="me",
|
||||||
feature_support=feature_support,
|
kobo_support=kobo_support,
|
||||||
registered_oauth=oauth_check, oauth_status=oauth_status)
|
registered_oauth=oauth_check, oauth_status=oauth_status)
|
||||||
if "nickname" in to_save and to_save["nickname"] != current_user.nickname:
|
if "nickname" in to_save and to_save["nickname"] != current_user.nickname:
|
||||||
# Query User nickname, if not existing, change
|
# Query User nickname, if not existing, change
|
||||||
|
@ -1323,7 +1325,7 @@ def profile():
|
||||||
return render_title_template("user_edit.html",
|
return render_title_template("user_edit.html",
|
||||||
translations=translations,
|
translations=translations,
|
||||||
languages=languages,
|
languages=languages,
|
||||||
feature_support=feature_support,
|
kobo_support=kobo_support,
|
||||||
new_user=0, content=current_user,
|
new_user=0, content=current_user,
|
||||||
downloads=downloads,
|
downloads=downloads,
|
||||||
registered_oauth=oauth_check,
|
registered_oauth=oauth_check,
|
||||||
|
@ -1355,13 +1357,13 @@ def profile():
|
||||||
flash(_(u"Found an existing account for this e-mail address."), category="error")
|
flash(_(u"Found an existing account for this e-mail address."), category="error")
|
||||||
log.debug(u"Found an existing account for this e-mail address.")
|
log.debug(u"Found an existing account for this e-mail address.")
|
||||||
return render_title_template("user_edit.html", content=current_user, downloads=downloads,
|
return render_title_template("user_edit.html", content=current_user, downloads=downloads,
|
||||||
translations=translations, feature_support=feature_support,
|
translations=translations, kobo_support=kobo_support,
|
||||||
title=_(u"%(name)s's profile", name=current_user.nickname), page="me",
|
title=_(u"%(name)s's profile", name=current_user.nickname), page="me",
|
||||||
registered_oauth=oauth_check, oauth_status=oauth_status)
|
registered_oauth=oauth_check, oauth_status=oauth_status)
|
||||||
flash(_(u"Profile updated"), category="success")
|
flash(_(u"Profile updated"), category="success")
|
||||||
log.debug(u"Profile updated")
|
log.debug(u"Profile updated")
|
||||||
return render_title_template("user_edit.html", translations=translations, profile=1, languages=languages,
|
return render_title_template("user_edit.html", translations=translations, profile=1, languages=languages,
|
||||||
content=current_user, downloads=downloads, feature_support=feature_support,
|
content=current_user, downloads=downloads, kobo_support=kobo_support,
|
||||||
title= _(u"%(name)s's profile", name=current_user.nickname),
|
title= _(u"%(name)s's profile", name=current_user.nickname),
|
||||||
page="me", registered_oauth=oauth_check, oauth_status=oauth_status)
|
page="me", registered_oauth=oauth_check, oauth_status=oauth_status)
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ rarfile>=2.7
|
||||||
# other
|
# other
|
||||||
natsort>=2.2.0
|
natsort>=2.2.0
|
||||||
git+https://github.com/OzzieIsaacs/comicapi.git@ad8bfe5a1c31db882480433f86db2c5c57634a3f#egg=comicapi
|
git+https://github.com/OzzieIsaacs/comicapi.git@ad8bfe5a1c31db882480433f86db2c5c57634a3f#egg=comicapi
|
||||||
#kobo integration
|
|
||||||
|
#Kobo integration
|
||||||
jsonschema>=3.2.0
|
jsonschema>=3.2.0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user