def delete_saiyan(name): for index, dbz_obj in enumerate(dbz_list): if dbz_obj.get('name') == name: dbz_list.pop(index) return resp.success_json(dbz_list) return resp.error_json( resp.InvalidInput(msg="Could Not find this character"))
def add_saiyan(): dbz_input = request.json for dbz_obj in dbz_list: if dbz_input.get('id') == dbz_obj.get('id'): return resp.error_json( resp.InvalidInput( msg="Already have some character from this id.")) dbz_list.append(request.json) return resp.success_json(dbz_list)
def update_saiyan(): dbz_input = request.json for index, dbz_obj in enumerate(dbz_list): if dbz_input.get('id') == dbz_obj.get('id'): dbz_list.pop(index) dbz_list.append(dbz_input) return resp.success_json(dbz_list) return resp.error_json( resp.InvalidInput(msg="Could Not find this character"))
def get_dbz_char(name): for index, dbz_obj in enumerate(dbz_list): if dbz_obj.get('name') == name: return resp.success_json(dbz_obj) return resp.error_json( resp.InvalidInput(msg="Could Not find this character"))
def get_dbz_list(): return resp.success_json(dbz_list)