|
|
|
@ -43,13 +43,27 @@ from jlog.log_api import renderTemplate
|
|
|
|
|
def log_list(request, offset):
|
|
|
|
|
""" 显示日志 """
|
|
|
|
|
header_title, path1, path2 = u'查看日志', u'查看日志', u'在线用户'
|
|
|
|
|
keyword = request.GET.get('keyword', '')
|
|
|
|
|
web_socket_host = CONF.get('websocket', 'web_socket_host')
|
|
|
|
|
keyword = request.GET.get('keyword', None)
|
|
|
|
|
# posts = get_user_log(get_user_info(request, offset))
|
|
|
|
|
|
|
|
|
|
if offset == 'online':
|
|
|
|
|
web_socket_host = CONF.get('websocket', 'web_socket_host')
|
|
|
|
|
posts = Log.objects.filter(is_finished=False).order_by('-start_time')
|
|
|
|
|
else:
|
|
|
|
|
posts = Log.objects.filter(is_finished=True).order_by('-start_time')
|
|
|
|
|
if keyword is not None:
|
|
|
|
|
date_seven_day = request.GET.get('start')
|
|
|
|
|
date_now_str = request.GET.get('end')
|
|
|
|
|
datetime_start = datetime.datetime.strptime(date_seven_day, '%m/%d/%Y')
|
|
|
|
|
datetime_end = datetime.datetime.strptime(date_now_str, '%m/%d/%Y')
|
|
|
|
|
print datetime_start, datetime_end
|
|
|
|
|
posts = posts.filter(start_time__gte=datetime_start).filter(start_time__lte=datetime_end).filter(
|
|
|
|
|
Q(user__icontains=keyword) | Q(host__icontains=keyword) | Q(remote_ip__icontains=keyword))
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
date_now = datetime.datetime.now()
|
|
|
|
|
date_now_str = date_now.strftime('%m/%d/%Y')
|
|
|
|
|
date_seven_day = (date_now + datetime.timedelta(days=-7)).strftime('%m/%d/%Y')
|
|
|
|
|
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(posts, request)
|
|
|
|
|
|
|
|
|
|
return render_to_response('jlog/log_%s.html' % offset, locals(), context_instance=RequestContext(request))
|
|
|
|
|