def rename(old_str=None, new_str=None, login_user=None): print(old_str, new_str, login_user) gs = HostGroup.select_vs(where='create_user = %s and come_from = %s', params=[login_user, 1]) for g in gs: HostGroup.update_dict( {'grp_name': g.grp_name.replace(old_str, new_str)}, 'id=%s', [g.id]) return ''
def group_update_post(group_id): group_id = int(group_id) new_name = request.form['new_name'].strip() if not new_name: return jsonify(msg='new name is blank') group = HostGroup.read(where='id = %s', params=[group_id]) if not group: return jsonify(msg='no such group') if not group.writable(g.user): return jsonify(msg='no permission') HostGroup.update_dict({'grp_name': new_name}, 'id=%s', [group_id]) return jsonify(msg='')
def group_update_post(group_id): group_id = int(group_id) new_name = request.form['new_name'].strip() if not new_name: return jsonify(msg='new name is blank') group = HostGroup.read(where='id = %s', params=[group_id]) if not group: return jsonify(msg='no such group') if not group.writable(g.user): return jsonify(msg='no permission') HostGroup.update_dict({'grp_name': new_name}, 'id=%s', [group_id]) return jsonify(msg='')