Commit c618d607 authored by Leon Tappe's avatar Leon Tappe 🔥
Browse files

update output of settings routes

parent fe3dfdf6
......@@ -570,9 +570,9 @@ def current_color():
def get_settings():
settings = Setting.query.all()
settings_map = []
settings_map = {}
for setting in settings:
settings_map.append({'key': setting.key, 'value': setting.value})
settings_map.append({setting.key: setting.value})
return jsonify(settings_map)
......@@ -588,7 +588,7 @@ def admin_settings():
db.session.add(setting)
db.session.commit()
new_setting = Setting.query.filter_by(key=setting.key).first()
return jsonify({'key': new_setting.key, 'value': new_setting.value})
return jsonify({new_setting.key : new_setting.value})
except:
return 'failed to add setting, check for duplicate key', 400
......@@ -598,13 +598,13 @@ def admin_settings():
def single_setting(key):
if request.method == 'GET':
setting = Setting.query.filter_by(key=key).first()
return jsonify({'key': setting.key, 'value': setting.value})
return jsonify({setting.key : setting.value})
if request.method == 'PUT':
if db.session.query(Setting).filter(Setting.key == key).update({Setting.value: request.json['value']}) < 1:
return 'not found', 404
db.session.commit()
new_setting = Setting.query.filter_by(key=key).first()
return jsonify({'key': new_setting.key, 'value': new_setting.value})
return jsonify({new_setting.key : new_setting.value})
if request.method == 'DELETE':
if db.session.query(Setting).filter(Setting.key == key).delete() < 1:
return 'not found', 404
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment