def backend_alive_user(request): obj_list = [] for node in Node.objects.all(): obj_list.extend(AliveIp.recent_alive(node.node_id)) page_num = 15 context = Page_List_View(request, obj_list, page_num).get_page_context() return render(request, 'backend/aliveuser.html', context=context)
def alive_ip_api(request): token = request.GET.get('token', '') if token == settings.TOKEN: data = json.loads(request.body)['data'] node_id = json.loads(request.body)['node_id'] model_list = [] for user, ip_list in data.items(): user = SSUser.objects.get(pk=user).user for ip in ip_list: model_list.append(AliveIp(node_id=node_id, user=user, ip=ip)) AliveIp.objects.bulk_create(model_list) re_dict = {'ret': 1, 'data': []} else: re_dict = {'ret': -1} return JsonResponse(re_dict)