diff --git a/jlog/views.py b/jlog/views.py index 53a954b17..0b99cd97d 100644 --- a/jlog/views.py +++ b/jlog/views.py @@ -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)) diff --git a/templates/head_script.html b/templates/head_script.html index ef5f7a190..28a394488 100644 --- a/templates/head_script.html +++ b/templates/head_script.html @@ -8,4 +8,5 @@ + diff --git a/templates/jlog/log_offline.html b/templates/jlog/log_offline.html index 91726cd4f..09de96f69 100644 --- a/templates/jlog/log_offline.html +++ b/templates/jlog/log_offline.html @@ -1,4 +1,7 @@ {% extends 'base.html' %} +{% block self_head_css_js %} + +{% endblock %} {% block content %} {% include 'nav_cat_bar.html' %} @@ -52,23 +55,21 @@
  • 在线
  • 历史记录
  • -
    +
    - + to - -
    +
    -
    +
    +
    -
    - - + +
    -
  • @@ -153,13 +154,14 @@ }); } - $("#search_input").keydown(function(e){ - if(e.keyCode==13){ - log_search() - } - }); +{# $("#search_input").keydown(function(e){#} +{# if(e.keyCode==13){#} +{# log_search()#} +{# }#} +{# });#} $('#data_5 .input-daterange').datepicker({ + dateFormat: 'yy-mm-dd', keyboardNavigation: false, forceParse: false, autoclose: true @@ -168,5 +170,6 @@ {% endblock %} {% block self_footer_js %} - + + {% endblock %} \ No newline at end of file