def backend_alive_user(request): user_list = [] for node_id in Node.get_node_ids_by_show(): user_list.extend(AliveIp.recent_alive(node_id)) page_num = 15 context = Page_List_View(request, user_list, page_num).get_page_context() return render(request, "backend/aliveuser.html", context=context)
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): data = request.json node_id = data["node_id"] model_list = [] for user_id, ip_list in data["data"].items(): user = User.objects.get(id=user_id) for ip in ip_list: model_list.append(AliveIp(node_id=node_id, user=user.username, ip=ip)) AliveIp.objects.bulk_create(model_list) res = {"ret": 1, "data": []} return JsonResponse(res)
def alive_ip_api(request): data = request.json node_id = data['node_id'] model_list = [] for user_id, ip_list in data['data'].items(): user = SSUser.objects.get(pk=user_id).user for ip in ip_list: model_list.append(AliveIp(node_id=node_id, user=user, ip=ip)) AliveIp.objects.bulk_create(model_list) res = {'ret': 1, 'data': []} return JsonResponse(res)
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) res = {'ret': 1, 'data': []} else: res = {'ret': -1} return JsonResponse(res)
def clean_online_ip_log(): """清空在线ip记录""" count = AliveIp.objects.count() AliveIp.truncate() print("Time: {} online ip log removed!:{}".format(timezone.now(), count))
def clean_online_ip_log(): '''清空在线ip记录''' count = TrafficLog.objects.count() AliveIp.truncate() print('Time: {} online ip log removed!:{}'.format(timezone.now(), count))