Fix config changing crash
This commit is contained in:
parent
e2380a5c74
commit
b1a1bd6c31
|
@ -238,10 +238,9 @@ def search():
|
||||||
@app.route('/config', methods=['GET', 'POST', 'PUT'])
|
@app.route('/config', methods=['GET', 'POST', 'PUT'])
|
||||||
@auth_required
|
@auth_required
|
||||||
def config():
|
def config():
|
||||||
if os.getenv('WHOOGLE_CONFIG_DISABLE_CHANGE', '') != '':
|
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
return json.dumps(g.user_config.__dict__)
|
return json.dumps(g.user_config.__dict__)
|
||||||
elif request.method == 'PUT':
|
elif request.method == 'PUT' and os.getenv('WHOOGLE_CONFIG_DISABLE_CHANGE', '') == '':
|
||||||
if 'name' in request.args:
|
if 'name' in request.args:
|
||||||
config_pkl = os.path.join(
|
config_pkl = os.path.join(
|
||||||
app.config['CONFIG_PATH'],
|
app.config['CONFIG_PATH'],
|
||||||
|
@ -252,7 +251,7 @@ def config():
|
||||||
return json.dumps(session['config'])
|
return json.dumps(session['config'])
|
||||||
else:
|
else:
|
||||||
return json.dumps({})
|
return json.dumps({})
|
||||||
else:
|
elif os.getenv('WHOOGLE_CONFIG_DISABLE_CHANGE', '') == '':
|
||||||
config_data = request.form.to_dict()
|
config_data = request.form.to_dict()
|
||||||
if 'url' not in config_data or not config_data['url']:
|
if 'url' not in config_data or not config_data['url']:
|
||||||
config_data['url'] = g.user_config.url
|
config_data['url'] = g.user_config.url
|
||||||
|
@ -272,6 +271,8 @@ def config():
|
||||||
|
|
||||||
session['config'] = config_data
|
session['config'] = config_data
|
||||||
return redirect(config_data['url'])
|
return redirect(config_data['url'])
|
||||||
|
else:
|
||||||
|
return json.dumps({})
|
||||||
|
|
||||||
|
|
||||||
@app.route('/url', methods=['GET'])
|
@app.route('/url', methods=['GET'])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user