def add(self, request): #创建/更新的页面 id = request.GET.get('id', 0) f = Falcon(request.user.username) expression_info = f.get_expression_info_by_id(id) print expression_info op_list = ['==', '!=', '<', '<=', '>', '>='] current_uic_list = expression_info['action']['uic'].split(',') all_uic = f.query_team() all_uic_list = [i['team']['name'] for i in all_uic] return render(request, 'alarm/expression_add.html', locals())
def update(self, request): template_id = request.GET['id'] f = Falcon() hostgroups = f.get_hostgroups_of_template(template_id) #当前模板下已关联的机器组 current_hostgroup_ids = [i['id'] for i in hostgroups['hostgroups']] template_info = f.get_template_info(template_id) print template_info all_template_list = f.get_all_template_list() all_template_list = all_template_list['templates'] print all_template_list all_hostgroup_list = f.get_all_hostgroup_list() op_list = ['==', '!=', '<', '<=', '>', '>='] cur_uic = template_info['action']['uic'] cur_uic_list = cur_uic.split(',') all_uic = f.query_team() all_uic_list = [i['team']['name'] for i in all_uic] return render(request, 'alarm/template_update.html', locals())
def data(self, request): name = request.GET['name'] limit = int(request.GET['limit']) page = int(request.GET['page']) f = Falcon() data = f.query_team(q=name) print data total = len(data) data = data[(page - 1) * limit:page * limit] result = [] for i in data: result.append({ 'id': i['team']['id'], 'name': i['team']['name'], 'resume': i['team']['resume'], 'creator_name': i['creator_name'] }) return HttpResponse(json.dumps({'total': total, 'rows': result}))