From 589d0d0fac44d1670e4d60807b3d537cb407c7de Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 27 Oct 2016 22:58:19 +0800 Subject: [PATCH] Finish command log list --- .../templates/audits/command_log_list.html | 129 +++++------------- apps/audits/views.py | 18 ++- apps/templates/_nav.html | 3 + 3 files changed, 54 insertions(+), 96 deletions(-) diff --git a/apps/audits/templates/audits/command_log_list.html b/apps/audits/templates/audits/command_log_list.html index cf93adfb3..6682273af 100644 --- a/apps/audits/templates/audits/command_log_list.html +++ b/apps/audits/templates/audits/command_log_list.html @@ -1,107 +1,46 @@ {% extends '_base_list.html' %} -{% load i18n static %} -{% block custom_head_css_js %} - {{ block.super }} +{% load i18n %} +{% load static %} +{% load common_tags %} +{% block content_left_head %} +{# {% trans "Create permission" %} #} - {% endblock %} -{% block table_search %}{% endblock %} + {% block table_container %} -{#
{% trans "Create user" %}
#} - +
- - - - - - {# #} - - - - - - - + + + + + + + + + {% for command in command_list %} + + + + + + + + + {% endfor %}
-
- -
-
{% trans 'Username' %}{% trans 'IP' %}{% trans 'System user' %}{% trans 'Login type' %}{% trans 'Command' %}{% trans 'Success' %}{% trans 'Finished' %}{% trans 'Date start' %}{% trans 'Time' %}{% trans 'Action' %}
IDCommandUsernameIPDatetimeOutput
{{ command.command_no }}{{ command.command }}{{ command.proxy_log.username }}{{ command.proxy_log.ip }}{{ command.datetime }}{{ command.output_decode |safe }}
{% endblock %} -{% block custom_foot_js %} - - - +{% block custom_foot_js %} + + {% endblock %} + + diff --git a/apps/audits/views.py b/apps/audits/views.py index 3c2ecf853..151c93967 100644 --- a/apps/audits/views.py +++ b/apps/audits/views.py @@ -51,8 +51,24 @@ class ProxyLogCommandsListView(AdminUserRequiredMixin, SingleObjectMixin, ListVi return list(self.object.command_log.all()) -class CommandLogListView(AdminUserRequiredMixin, TemplateView): +class CommandLogListView(AdminUserRequiredMixin, ListView): + model = CommandLog template_name = 'audits/command_log_list.html' + paginate_by = settings.CONFIG.DISPLAY_PER_PAGE + context_object_name = 'command_list' + + def get_queryset(self): + # Todo: Default order by lose asset connection num + self.queryset = super(CommandLogListView, self).get_queryset() + self.keyword = keyword = self.request.GET.get('keyword', '') + self.sort = sort = self.request.GET.get('sort', '-datetime') + + if keyword: + self.queryset = self.queryset.filter() + + if sort: + self.queryset = self.queryset.order_by(sort) + return self.queryset def get_context_data(self, **kwargs): context = { diff --git a/apps/templates/_nav.html b/apps/templates/_nav.html index decfa38fc..3cb8a0e87 100644 --- a/apps/templates/_nav.html +++ b/apps/templates/_nav.html @@ -45,6 +45,9 @@
  • {% trans 'Proxy log' %}
  • +
  • + {% trans 'Command log' %} +
  • {% trans 'Login log' %}