@ -40,7 +40,7 @@ from sqlalchemy.exc import IntegrityError, OperationalError, InvalidRequestError
from sqlalchemy . sql . expression import func , or_ , text
from sqlalchemy . sql . expression import func , or_ , text
from . import constants , logger , helper , services
from . import constants , logger , helper , services
from . cli import filepicker
# from .cli import filepicker
from . import db , calibre_db , ub , web_server , get_locale , config , updater_thread , babel , gdriveutils
from . import db , calibre_db , ub , web_server , get_locale , config , updater_thread , babel , gdriveutils
from . helper import check_valid_domain , send_test_mail , reset_password , generate_password_hash , check_email , \
from . helper import check_valid_domain , send_test_mail , reset_password , generate_password_hash , check_email , \
valid_email , check_username
valid_email , check_username
@ -97,19 +97,6 @@ def admin_required(f):
return inner
return inner
def unconfigured ( f ) :
"""
Checks if calibre - web instance is not configured
"""
@wraps ( f )
def inner ( * args , * * kwargs ) :
if not config . db_configured :
return f ( * args , * * kwargs )
abort ( 403 )
return inner
@admi.before_app_request
@admi.before_app_request
def before_request ( ) :
def before_request ( ) :
if current_user . is_authenticated :
if current_user . is_authenticated :
@ -124,10 +111,14 @@ def before_request():
g . shelves_access = ub . session . query ( ub . Shelf ) . filter (
g . shelves_access = ub . session . query ( ub . Shelf ) . filter (
or_ ( ub . Shelf . is_public == 1 , ub . Shelf . user_id == current_user . id ) ) . order_by ( ub . Shelf . name ) . all ( )
or_ ( ub . Shelf . is_public == 1 , ub . Shelf . user_id == current_user . id ) ) . order_by ( ub . Shelf . name ) . all ( )
if ' /static/ ' not in request . path and not config . db_configured and \
if ' /static/ ' not in request . path and not config . db_configured and \
request . endpoint not in ( ' admin.basic_configuration ' ,
request . endpoint not in ( ' admin.ajax_db_config ' ,
' login ' ,
' admin.simulatedbchange ' ,
' admin.config_pathchooser ' ) :
' admin.db_configuration ' ,
return redirect ( url_for ( ' admin.basic_configuration ' ) )
' web.login ' ,
' web.logout ' ,
' admin.load_dialogtexts ' ,
' admin.ajax_pathchooser ' ) :
return redirect ( url_for ( ' admin.db_configuration ' ) )
@admi.route ( " /admin " )
@admi.route ( " /admin " )
@ -194,15 +185,45 @@ def admin():
feature_support = feature_support , kobo_support = kobo_support ,
feature_support = feature_support , kobo_support = kobo_support ,
title = _ ( u " Admin page " ) , page = " admin " )
title = _ ( u " Admin page " ) , page = " admin " )
@admi.route ( " /admin/dbconfig " , methods = [ " GET " , " POST " ] )
@login_required
@admin_required
def db_configuration ( ) :
if request . method == " POST " :
return _db_configuration_update_helper ( )
return _db_configuration_result ( )
@admi.route ( " /admin/config " , methods = [ " GET " , " POST " ] )
@admi.route ( " /admin/config " , methods = [ " GET " ])
@login_required
@login_required
@admin_required
@admin_required
def configuration ( ) :
def configuration ( ) :
if request . method == " POST " :
return render_title_template ( " config_edit.html " ,
return _configuration_update_helper ( True )
config = config ,
return _configuration_result ( )
provider = oauthblueprints ,
feature_support = feature_support ,
title = _ ( u " Basic Configuration " ) , page = " config " )
@admi.route ( " /admin/ajaxconfig " , methods = [ " POST " ] )
@login_required
@admin_required
def ajax_config ( ) :
return _configuration_update_helper ( )
@admi.route ( " /admin/ajaxdbconfig " , methods = [ " POST " ] )
@login_required
@admin_required
def ajax_db_config ( ) :
return _db_configuration_update_helper ( )
@admi.route ( " /admin/alive " , methods = [ " GET " ] )
@login_required
@admin_required
def calibreweb_alive ( ) :
return " " , 200
@admi.route ( " /admin/viewconfig " )
@admi.route ( " /admin/viewconfig " )
@login_required
@login_required
@ -539,10 +560,10 @@ def update_view_configuration():
return view_configuration ( )
return view_configuration ( )
@admi.route ( " /ajax/loaddialogtexts/<element_id> " )
@admi.route ( " /ajax/loaddialogtexts/<element_id> " , methods = [ ' POST ' ] )
@login_required
@login_required
def load_dialogtexts ( element_id ) :
def load_dialogtexts ( element_id ) :
texts = { " header " : " " , " main " : " " }
texts = { " header " : " " , " main " : " " , " valid " : 1 }
if element_id == " config_delete_kobo_token " :
if element_id == " config_delete_kobo_token " :
texts [ " main " ] = _ ( ' Do you really want to delete the Kobo Token? ' )
texts [ " main " ] = _ ( ' Do you really want to delete the Kobo Token? ' )
elif element_id == " btndeletedomain " :
elif element_id == " btndeletedomain " :
@ -563,6 +584,8 @@ def load_dialogtexts(element_id):
texts [ " main " ] = _ ( ' Are you sure you want to change the selected visibility restrictions for the selected user(s)? ' )
texts [ " main " ] = _ ( ' Are you sure you want to change the selected visibility restrictions for the selected user(s)? ' )
elif element_id == " kobo_only_shelves_sync " :
elif element_id == " kobo_only_shelves_sync " :
texts [ " main " ] = _ ( ' Are you sure you want to change shelf sync behavior for the selected user(s)? ' )
texts [ " main " ] = _ ( ' Are you sure you want to change shelf sync behavior for the selected user(s)? ' )
elif element_id == " db_submit " :
texts [ " main " ] = _ ( ' Are you sure you want to change Calibre libray location? ' )
return json . dumps ( texts )
return json . dumps ( texts )
@ -867,14 +890,6 @@ def list_restriction(res_type, user_id):
return response
return response
@admi.route ( " /basicconfig/pathchooser/ " )
@unconfigured
def config_pathchooser ( ) :
if filepicker :
return pathchooser ( )
abort ( 403 )
@admi.route ( " /ajax/pathchooser/ " )
@admi.route ( " /ajax/pathchooser/ " )
@login_required
@login_required
@admin_required
@admin_required
@ -963,16 +978,6 @@ def pathchooser():
return json . dumps ( context )
return json . dumps ( context )
@admi.route ( " /basicconfig " , methods = [ " GET " , " POST " ] )
@unconfigured
def basic_configuration ( ) :
logout_user ( )
if request . method == " POST " :
log . debug ( " Basic Configuration send " )
return _configuration_update_helper ( configured = filepicker )
return _configuration_result ( configured = filepicker )
def _config_int ( to_save , x , func = int ) :
def _config_int ( to_save , x , func = int ) :
return config . set_from_dictionary ( to_save , x , func )
return config . set_from_dictionary ( to_save , x , func )
@ -991,6 +996,7 @@ def _config_string(to_save, x):
def _configuration_gdrive_helper ( to_save ) :
def _configuration_gdrive_helper ( to_save ) :
gdrive_error = None
gdrive_error = None
if to_save . get ( " config_use_google_drive " ) :
gdrive_secrets = { }
gdrive_secrets = { }
if not os . path . isfile ( gdriveutils . SETTINGS_YAML ) :
if not os . path . isfile ( gdriveutils . SETTINGS_YAML ) :
@ -1041,23 +1047,23 @@ def _configuration_oauth_helper(to_save):
return reboot_required
return reboot_required
def _configuration_logfile_helper ( to_save , gdrive_error ):
def _configuration_logfile_helper ( to_save ):
reboot_required = False
reboot_required = False
reboot_required | = _config_int ( to_save , " config_log_level " )
reboot_required | = _config_int ( to_save , " config_log_level " )
reboot_required | = _config_string ( to_save , " config_logfile " )
reboot_required | = _config_string ( to_save , " config_logfile " )
if not logger . is_valid_logfile ( config . config_logfile ) :
if not logger . is_valid_logfile ( config . config_logfile ) :
return reboot_required , \
return reboot_required , \
_configuration_result ( _ ( ' Logfile Location is not Valid, Please Enter Correct Path ' ) , gdrive_error )
_configuration_result ( _ ( ' Logfile Location is not Valid, Please Enter Correct Path ' ) )
reboot_required | = _config_checkbox_int ( to_save , " config_access_log " )
reboot_required | = _config_checkbox_int ( to_save , " config_access_log " )
reboot_required | = _config_string ( to_save , " config_access_logfile " )
reboot_required | = _config_string ( to_save , " config_access_logfile " )
if not logger . is_valid_logfile ( config . config_access_logfile ) :
if not logger . is_valid_logfile ( config . config_access_logfile ) :
return reboot_required , \
return reboot_required , \
_configuration_result ( _ ( ' Access Logfile Location is not Valid, Please Enter Correct Path ' ) , gdrive_error )
_configuration_result ( _ ( ' Access Logfile Location is not Valid, Please Enter Correct Path ' ) )
return reboot_required , None
return reboot_required , None
def _configuration_ldap_helper ( to_save , gdrive_error ):
def _configuration_ldap_helper ( to_save ):
reboot_required = False
reboot_required = False
reboot_required | = _config_string ( to_save , " config_ldap_provider_url " )
reboot_required | = _config_string ( to_save , " config_ldap_provider_url " )
reboot_required | = _config_int ( to_save , " config_ldap_port " )
reboot_required | = _config_int ( to_save , " config_ldap_port " )
@ -1084,44 +1090,37 @@ def _configuration_ldap_helper(to_save, gdrive_error):
or not config . config_ldap_dn \
or not config . config_ldap_dn \
or not config . config_ldap_user_object :
or not config . config_ldap_user_object :
return reboot_required , _configuration_result ( _ ( ' Please Enter a LDAP Provider, '
return reboot_required , _configuration_result ( _ ( ' Please Enter a LDAP Provider, '
' Port, DN and User Object Identifier ' ) , gdrive_error )
' Port, DN and User Object Identifier ' ) )
if config . config_ldap_authentication > constants . LDAP_AUTH_ANONYMOUS :
if config . config_ldap_authentication > constants . LDAP_AUTH_ANONYMOUS :
if config . config_ldap_authentication > constants . LDAP_AUTH_UNAUTHENTICATE :
if config . config_ldap_authentication > constants . LDAP_AUTH_UNAUTHENTICATE :
if not config . config_ldap_serv_username or not bool ( config . config_ldap_serv_password ) :
if not config . config_ldap_serv_username or not bool ( config . config_ldap_serv_password ) :
return reboot_required , _configuration_result ( ' Please Enter a LDAP Service Account and Password ' ,
return reboot_required , _configuration_result ( _ ( ' Please Enter a LDAP Service Account and Password ' ) )
gdrive_error )
else :
else :
if not config . config_ldap_serv_username :
if not config . config_ldap_serv_username :
return reboot_required , _configuration_result ( ' Please Enter a LDAP Service Account ' , gdrive_error )
return reboot_required , _configuration_result ( _ ( ' Please Enter a LDAP Service Account ' ) )
if config . config_ldap_group_object_filter :
if config . config_ldap_group_object_filter :
if config . config_ldap_group_object_filter . count ( " %s " ) != 1 :
if config . config_ldap_group_object_filter . count ( " %s " ) != 1 :
return reboot_required , \
return reboot_required , \
_configuration_result ( _ ( ' LDAP Group Object Filter Needs to Have One " %s " Format Identifier ' ) ,
_configuration_result ( _ ( ' LDAP Group Object Filter Needs to Have One " %s " Format Identifier ' ) )
gdrive_error )
if config . config_ldap_group_object_filter . count ( " ( " ) != config . config_ldap_group_object_filter . count ( " ) " ) :
if config . config_ldap_group_object_filter . count ( " ( " ) != config . config_ldap_group_object_filter . count ( " ) " ) :
return reboot_required , _configuration_result ( _ ( ' LDAP Group Object Filter Has Unmatched Parenthesis ' ) ,
return reboot_required , _configuration_result ( _ ( ' LDAP Group Object Filter Has Unmatched Parenthesis ' ) )
gdrive_error )
if config . config_ldap_user_object . count ( " %s " ) != 1 :
if config . config_ldap_user_object . count ( " %s " ) != 1 :
return reboot_required , \
return reboot_required , \
_configuration_result ( _ ( ' LDAP User Object Filter needs to Have One " %s " Format Identifier ' ) ,
_configuration_result ( _ ( ' LDAP User Object Filter needs to Have One " %s " Format Identifier ' ) )
gdrive_error )
if config . config_ldap_user_object . count ( " ( " ) != config . config_ldap_user_object . count ( " ) " ) :
if config . config_ldap_user_object . count ( " ( " ) != config . config_ldap_user_object . count ( " ) " ) :
return reboot_required , _configuration_result ( _ ( ' LDAP User Object Filter Has Unmatched Parenthesis ' ) ,
return reboot_required , _configuration_result ( _ ( ' LDAP User Object Filter Has Unmatched Parenthesis ' ) )
gdrive_error )
if to_save . get ( " ldap_import_user_filter " ) == ' 0 ' :
if to_save . get ( " ldap_import_user_filter " ) == ' 0 ' :
config . config_ldap_member_user_object = " "
config . config_ldap_member_user_object = " "
else :
else :
if config . config_ldap_member_user_object . count ( " %s " ) != 1 :
if config . config_ldap_member_user_object . count ( " %s " ) != 1 :
return reboot_required , \
return reboot_required , \
_configuration_result ( _ ( ' LDAP Member User Filter needs to Have One " %s " Format Identifier ' ) ,
_configuration_result ( _ ( ' LDAP Member User Filter needs to Have One " %s " Format Identifier ' ) )
gdrive_error )
if config . config_ldap_member_user_object . count ( " ( " ) != config . config_ldap_member_user_object . count ( " ) " ) :
if config . config_ldap_member_user_object . count ( " ( " ) != config . config_ldap_member_user_object . count ( " ) " ) :
return reboot_required , _configuration_result ( _ ( ' LDAP Member User Filter Has Unmatched Parenthesis ' ) ,
return reboot_required , _configuration_result ( _ ( ' LDAP Member User Filter Has Unmatched Parenthesis ' ) )
gdrive_error )
if config . config_ldap_cacert_path or config . config_ldap_cert_path or config . config_ldap_key_path :
if config . config_ldap_cacert_path or config . config_ldap_cert_path or config . config_ldap_key_path :
if not ( os . path . isfile ( config . config_ldap_cacert_path ) and
if not ( os . path . isfile ( config . config_ldap_cacert_path ) and
@ -1129,13 +1128,31 @@ def _configuration_ldap_helper(to_save, gdrive_error):
os . path . isfile ( config . config_ldap_key_path ) ) :
os . path . isfile ( config . config_ldap_key_path ) ) :
return reboot_required , \
return reboot_required , \
_configuration_result ( _ ( ' LDAP CACertificate, Certificate or Key Location is not Valid, '
_configuration_result ( _ ( ' LDAP CACertificate, Certificate or Key Location is not Valid, '
' Please Enter Correct Path ' ) ,
' Please Enter Correct Path ' ) )
gdrive_error )
return reboot_required , None
return reboot_required , None
def _configuration_update_helper ( configured ) :
@admi.route ( " /ajax/simulatedbchange " , methods = [ ' POST ' ] )
reboot_required = False
@login_required
@admin_required
def simulatedbchange ( ) :
db_change , db_valid = _db_simulate_change ( )
return Response ( json . dumps ( { " change " : db_change , " valid " : db_valid } ) , mimetype = ' application/json ' )
def _db_simulate_change ( ) :
param = request . form . to_dict ( )
to_save = { }
to_save [ ' config_calibre_dir ' ] = re . sub ( r ' [ \\ /]metadata \ .db$ ' ,
' ' ,
param [ ' config_calibre_dir ' ] ,
flags = re . IGNORECASE ) . strip ( )
db_change = config . config_calibre_dir != to_save [ " config_calibre_dir " ] and config . config_calibre_dir
db_valid = calibre_db . check_valid_db ( to_save [ " config_calibre_dir " ] , ub . app_DB_path )
return db_change , db_valid
def _db_configuration_update_helper ( ) :
db_change = False
db_change = False
to_save = request . form . to_dict ( )
to_save = request . form . to_dict ( )
gdrive_error = None
gdrive_error = None
@ -1145,24 +1162,47 @@ def _configuration_update_helper(configured):
to_save [ ' config_calibre_dir ' ] ,
to_save [ ' config_calibre_dir ' ] ,
flags = re . IGNORECASE )
flags = re . IGNORECASE )
try :
try :
db_change | = _config_string ( to_save , " config_calibre_dir " )
db_change , db_valid = _db_simulate_change ( )
# gdrive_error drive setup
# gdrive_error drive setup
gdrive_error = _configuration_gdrive_helper ( to_save )
gdrive_error = _configuration_gdrive_helper ( to_save )
except ( OperationalError , InvalidRequestError ) :
ub . session . rollback ( )
log . error ( " Settings DB is not Writeable " )
_db_configuration_result ( _ ( " Settings DB is not Writeable " ) , gdrive_error )
try :
metadata_db = os . path . join ( to_save [ ' config_calibre_dir ' ] , " metadata.db " )
if config . config_use_google_drive and is_gdrive_ready ( ) and not os . path . exists ( metadata_db ) :
gdriveutils . downloadFile ( None , " metadata.db " , metadata_db )
db_change = True
except Exception as ex :
return _db_configuration_result ( ' {} ' . format ( ex ) , gdrive_error )
if db_change or not db_valid or not config . db_configured :
if not calibre_db . setup_db ( to_save [ ' config_calibre_dir ' ] , ub . app_DB_path ) :
return _db_configuration_result ( _ ( ' DB Location is not Valid, Please Enter Correct Path ' ) ,
gdrive_error )
_config_string ( to_save , " config_calibre_dir " )
calibre_db . update_config ( config )
if not os . access ( os . path . join ( config . config_calibre_dir , " metadata.db " ) , os . W_OK ) :
flash ( _ ( u " DB is not Writeable " ) , category = " warning " )
# warning = {'type': "warning", 'message': _(u"DB is not Writeable")}
config . save ( )
return _db_configuration_result ( None , gdrive_error )
def _configuration_update_helper ( ) :
reboot_required = False
to_save = request . form . to_dict ( )
try :
reboot_required | = _config_int ( to_save , " config_port " )
reboot_required | = _config_int ( to_save , " config_port " )
reboot_required | = _config_string ( to_save , " config_keyfile " )
reboot_required | = _config_string ( to_save , " config_keyfile " )
if config . config_keyfile and not os . path . isfile ( config . config_keyfile ) :
if config . config_keyfile and not os . path . isfile ( config . config_keyfile ) :
return _configuration_result ( _ ( ' Keyfile Location is not Valid, Please Enter Correct Path ' ) ,
return _configuration_result ( _ ( ' Keyfile Location is not Valid, Please Enter Correct Path ' ) )
gdrive_error ,
configured )
reboot_required | = _config_string ( to_save , " config_certfile " )
reboot_required | = _config_string ( to_save , " config_certfile " )
if config . config_certfile and not os . path . isfile ( config . config_certfile ) :
if config . config_certfile and not os . path . isfile ( config . config_certfile ) :
return _configuration_result ( _ ( ' Certfile Location is not Valid, Please Enter Correct Path ' ) ,
return _configuration_result ( _ ( ' Certfile Location is not Valid, Please Enter Correct Path ' ) )
gdrive_error ,
configured )
_config_checkbox_int ( to_save , " config_uploading " )
_config_checkbox_int ( to_save , " config_uploading " )
# Reboot on config_anonbrowse with enabled ldap, as decoraters are changed in this case
# Reboot on config_anonbrowse with enabled ldap, as decoraters are changed in this case
@ -1186,15 +1226,14 @@ def _configuration_update_helper(configured):
reboot_required | = _config_int ( to_save , " config_login_type " )
reboot_required | = _config_int ( to_save , " config_login_type " )
# LDAP configurator ,
# LDAP configurator
if config . config_login_type == constants . LOGIN_LDAP :
if config . config_login_type == constants . LOGIN_LDAP :
reboot , message = _configuration_ldap_helper ( to_save , gdrive_error )
reboot , message = _configuration_ldap_helper ( to_save )
if message :
if message :
return message
return message
reboot_required | = reboot
reboot_required | = reboot
# Remote login configuration
# Remote login configuration
_config_checkbox ( to_save , " config_remote_login " )
_config_checkbox ( to_save , " config_remote_login " )
if not config . config_remote_login :
if not config . config_remote_login :
ub . session . query ( ub . RemoteAuthToken ) . filter ( ub . RemoteAuthToken . token_type == 0 ) . delete ( )
ub . session . query ( ub . RemoteAuthToken ) . filter ( ub . RemoteAuthToken . token_type == 0 ) . delete ( )
@ -1218,7 +1257,7 @@ def _configuration_update_helper(configured):
if config . config_login_type == constants . LOGIN_OAUTH :
if config . config_login_type == constants . LOGIN_OAUTH :
reboot_required | = _configuration_oauth_helper ( to_save )
reboot_required | = _configuration_oauth_helper ( to_save )
reboot , message = _configuration_logfile_helper ( to_save , gdrive_error )
reboot , message = _configuration_logfile_helper ( to_save )
if message :
if message :
return message
return message
reboot_required | = reboot
reboot_required | = reboot
@ -1227,67 +1266,55 @@ def _configuration_update_helper(configured):
if " config_rarfile_location " in to_save :
if " config_rarfile_location " in to_save :
unrar_status = helper . check_unrar ( config . config_rarfile_location )
unrar_status = helper . check_unrar ( config . config_rarfile_location )
if unrar_status :
if unrar_status :
return _configuration_result ( unrar_status , gdrive_error , configured )
return _configuration_result ( unrar_status )
except ( OperationalError , InvalidRequestError ) :
except ( OperationalError , InvalidRequestError ) :
ub . session . rollback ( )
ub . session . rollback ( )
log . error ( " Settings DB is not Writeable " )
log . error ( " Settings DB is not Writeable " )
_configuration_result ( _ ( " Settings DB is not Writeable " ) , gdrive_error , configured )
_configuration_result ( _ ( " Settings DB is not Writeable " ) )
try :
metadata_db = os . path . join ( config . config_calibre_dir , " metadata.db " )
if config . config_use_google_drive and is_gdrive_ready ( ) and not os . path . exists ( metadata_db ) :
gdriveutils . downloadFile ( None , " metadata.db " , metadata_db )
db_change = True
except Exception as ex :
return _configuration_result ( ' %s ' % ex , gdrive_error , configured )
if db_change :
if not calibre_db . setup_db ( config , ub . app_DB_path ) :
return _configuration_result ( _ ( ' DB Location is not Valid, Please Enter Correct Path ' ) ,
gdrive_error ,
configured )
if not os . access ( os . path . join ( config . config_calibre_dir , " metadata.db " ) , os . W_OK ) :
flash ( _ ( u " DB is not Writeable " ) , category = " warning " )
config . save ( )
config . save ( )
flash ( _ ( u " Calibre-Web configuration updated " ) , category = " success " )
if reboot_required :
if reboot_required :
web_server . stop ( True )
web_server . stop ( True )
return _configuration_result ( None , gdrive_error, configu red)
return _configuration_result ( None , reboot_required )
def _configuration_result ( error_flash = None , reboot = False ) :
resp = { }
if error_flash :
log . error ( error_flash )
config . load ( )
resp [ ' result ' ] = [ { ' type ' : " danger " , ' message ' : error_flash } ]
else :
resp [ ' result ' ] = [ { ' type ' : " success " , ' message ' : _ ( u " Calibre-Web configuration updated " ) } ]
resp [ ' reboot ' ] = reboot
resp [ ' config_upload ' ] = config . config_upload_formats
return Response ( json . dumps ( resp ) , mimetype = ' application/json ' )
def _configuration_result ( error_flash = None , gdrive_error = None , configured = True ) :
def _db_configuration_result ( error_flash = None , gdrive_error = None ) :
gdrive_authenticate = not is_gdrive_ready ( )
gdrive_authenticate = not is_gdrive_ready ( )
gdrivefolders = [ ]
gdrivefolders = [ ]
if gdrive_error is None :
if not gdrive_error and config . config_use_google_driv e:
gdrive_error = gdriveutils . get_error_text ( )
gdrive_error = gdriveutils . get_error_text ( )
if gdrive_error and gdrive_support :
if gdrive_error and gdrive_support :
log . error ( gdrive_error )
log . error ( gdrive_error )
gdrive_error = _ ( gdrive_error )
gdrive_error = _ ( gdrive_error )
flash ( gdrive_error , category = " error " )
else :
else :
if not gdrive_authenticate and gdrive_support :
if not gdrive_authenticate and gdrive_support :
gdrivefolders = gdriveutils . listRootFolders ( )
gdrivefolders = gdriveutils . listRootFolders ( )
show_back_button = current_user . is_authenticated
show_login_button = config . db_configured and not current_user . is_authenticated
if error_flash :
if error_flash :
log . error ( error_flash )
log . error ( error_flash )
config . load ( )
config . load ( )
flash ( error_flash , category = " error " )
flash ( error_flash , category = " error " )
show_login_button = False
return render_title_template ( " config_ edit .html" ,
return render_title_template ( " config_ db .html" ,
config = config ,
config = config ,
provider = oauthblueprints ,
show_back_button = show_back_button ,
show_login_button = show_login_button ,
show_authenticate_google_drive = gdrive_authenticate ,
show_authenticate_google_drive = gdrive_authenticate ,
filepicker = configured ,
gdriveError = gdrive_error ,
gdriveError = gdrive_error ,
gdrivefolders = gdrivefolders ,
gdrivefolders = gdrivefolders ,
feature_support = feature_support ,
feature_support = feature_support ,
title = _ ( u " Basic Configuration" ) , page = " config" )
title = _ ( u " Database Configuration" ) , page = " db config" )
def _handle_new_user ( to_save , content , languages , translations , kobo_support ) :
def _handle_new_user ( to_save , content , languages , translations , kobo_support ) :