def new_configuration(image_id): config = request.form['config'] name = request.form['name'] comment = request.form['comment'] saved, message = image_handler.save_configuration(image_id, config, name, comment) if saved: to_return = { "saved" : True } else: to_return = { "saved" : False, 'message' : message } response = make_response() response.data = json.dumps(to_return) response.mimetype = 'application/json' return response
def configuration(image_id, config_id): if request.method == 'GET': to_return = image_handler.get_configuration(image_id, config_id) elif request.method == 'POST': configuration = request.args.get('config') comment = request.args.gt("comment") if image_handler.save_configuration(image_id, configuration, comment): to_return = { "saved" : True } else: to_return = { "saved" : False } elif request.method == 'DELETE': if image_handler.delete_configuration(image_id, config_id): to_return = { "deleted" : True, "config_id" : config_id } else: to_return = { "deleted" : False, 'message' : 'Delete of ' + config_id + ' failed.' } response = make_response() response.data = json.dumps(to_return) response.mimetype = 'application/json' return response