def event_center(request): '''事件中心''' # 返回事件event。tables.table_filter函数已经帮你找出过滤条件,并且根据过滤条件到models.EventLog去获取到了数据 eventlog_objs = tables.table_filter(request, admin.EventLogAdmin, models.EventLog) # 排序之后的结果 order_res = tables.get_orderby(request, eventlog_objs, admin.EventLogAdmin) # 分页,每页100条数据展示 paginator = Paginator(order_res[0], admin.EventLogAdmin.list_per_page) page = request.GET.get('page') try: objs = paginator.page(page) except PageNotAnInteger: objs = paginator.page(1) except EmptyPage: objs = paginator.page(paginator.num_pages) table_obj = tables.TableHandler(request, models.EventLog, admin.EventLogAdmin, objs, order_res) return render(request, 'assets/event_center.html', { 'table_obj': table_obj, 'paginator': paginator })
def asset_list(request): # 获取资产,tables的table_filter函数就是用来找出过滤条件,筛选出对应资产 asset_obj_list = tables.table_filter(request, admin.AssetAdmin, models.Asset) #print("asset_obj_list:", asset_obj_list) # asset_obj_list 是类似于 [<Asset: <id:15 name:TestServer>>, <Asset: <id:16 name:Ubuntu>>] # 排序的结果 order_res = tables.get_orderby(request, asset_obj_list, admin.AssetAdmin) # 翻页,list_per_page每页多少条数据 paginator = Paginator(order_res[0], admin.AssetAdmin.list_per_page) # 从请求中获取到的页码,客户请求的是第几页 page = request.GET.get('page') try: asset_objs = paginator.page(page) except PageNotAnInteger: asset_objs = paginator.page(1) except EmptyPage: asset_objs = paginator.page(paginator.num_pages) # table_obj就是页面所需要展示的数据 table_obj = tables.TableHandler(request, models.Asset, admin.AssetAdmin, asset_objs, order_res) return render(request, 'assets/assets.html', { 'table_obj': table_obj, 'paginator': paginator })
def asset_list(request): print(request.GET) asset_obj_list = tables.table_filter(request, admin.AssetAdmin, models.Asset) # asset_obj_list = models.Asset.objects.all() print("asset_obj_list:", asset_obj_list) order_res = tables.get_orderby(request, asset_obj_list, admin.AssetAdmin) # print('----->',order_res) paginator = Paginator(order_res[0], admin.AssetAdmin.list_per_page) page = request.GET.get('page') try: asset_objs = paginator.page(page) except PageNotAnInteger: asset_objs = paginator.page(1) except EmptyPage: asset_objs = paginator.page(paginator.num_pages) table_obj = tables.TableHandler(request, models.Asset, admin.AssetAdmin, asset_objs, order_res ) return render(request, 'assets/assets.html', {'table_obj': table_obj, 'paginator': paginator})
def event_center(request): '''事件中心''' eventlog_objs = tables.table_filter(request, admin.EventLogAdmin, models.EventLog) # asset_obj_list = models.Asset.objects.all() # print("asset_obj_list:", asset_obj_list) order_res = tables.get_orderby(request, eventlog_objs, admin.EventLogAdmin) # print('----->',order_res) paginator = Paginator(order_res[0], admin.EventLogAdmin.list_per_page) page = request.GET.get('page') try: objs = paginator.page(page) except PageNotAnInteger: objs = paginator.page(1) except EmptyPage: objs = paginator.page(paginator.num_pages) table_obj = tables.TableHandler(request, models.EventLog, admin.EventLogAdmin, objs, order_res ) return render(request, 'assets/event_center.html', {'table_obj': table_obj, 'paginator': paginator})
def event_center(request): '''事件中心''' eventlog_objs = tables.table_filter(request, admin.EventLogAdmin, models.EventLog) # asset_obj_list = models.Asset.objects.all() #print("asset_obj_list:", asset_obj_list) order_res = tables.get_orderby(request, eventlog_objs, admin.EventLogAdmin) # print('----->',order_res) paginator = Paginator(order_res[0], admin.EventLogAdmin.list_per_page) page = request.GET.get('page') try: objs = paginator.page(page) except PageNotAnInteger: objs = paginator.page(1) except EmptyPage: objs = paginator.page(paginator.num_pages) table_obj = tables.TableHandler(request, models.EventLog, admin.EventLogAdmin, objs, order_res ) return render(request,'assets/event_center.html',{'table_obj': table_obj, 'paginator': paginator})
def operation_audit(request): '''行为审计''' auditlog_objs = tables.table_filter(request, admin.OperationAuditLogAdmin, models.OperationAuditLog) # asset_obj_list = models.Asset.objects.all() #print("asset_obj_list:", asset_obj_list) order_res = tables.get_orderby(request, auditlog_objs, admin.OperationAuditLogAdmin) # print('----->',order_res) paginator = Paginator(order_res[0], admin.OperationAuditLogAdmin.list_per_page) page = request.GET.get('page') try: objs = paginator.page(page) except PageNotAnInteger: objs = paginator.page(1) except EmptyPage: objs = paginator.page(paginator.num_pages) table_obj = tables.TableHandler(request, models.OperationAuditLog, admin.OperationAuditLogAdmin, objs, order_res ) return render(request,'hosts/operation_audit.html',{'table_obj': table_obj, 'paginator': paginator})