From 3c00c578c369717d2b6f93efdc25b58d267c2f64 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 27 Oct 2016 19:35:02 +0800 Subject: [PATCH] Update some vie --- apps/audits/serializers.py | 5 +- .../templates/audits/command_log_list.html | 107 ++++++++++++++++++ apps/audits/urls.py | 1 + apps/audits/views.py | 17 ++- 4 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 apps/audits/templates/audits/command_log_list.html diff --git a/apps/audits/serializers.py b/apps/audits/serializers.py index 5191e044b..881f84666 100644 --- a/apps/audits/serializers.py +++ b/apps/audits/serializers.py @@ -18,7 +18,10 @@ class ProxyLogSerializer(serializers.ModelSerializer): @staticmethod def get_time(obj): - return timesince(obj.date_start, since=obj.date_finished) + if not obj.is_finished: + return '' + else: + return timesince(obj.date_start, since=obj.date_finished) @staticmethod def get_command_length(obj): diff --git a/apps/audits/templates/audits/command_log_list.html b/apps/audits/templates/audits/command_log_list.html new file mode 100644 index 000000000..cf93adfb3 --- /dev/null +++ b/apps/audits/templates/audits/command_log_list.html @@ -0,0 +1,107 @@ +{% extends '_base_list.html' %} +{% load i18n static %} +{% block custom_head_css_js %} + {{ block.super }} + + +{% endblock %} +{% block table_search %}{% endblock %} +{% block table_container %} +{#
{% trans "Create user" %}
#} + + + + + + + + {# #} + + + + + + + + + + +
+
+ +
+
{% trans 'Username' %}{% trans 'IP' %}{% trans 'System user' %}{% trans 'Login type' %}{% trans 'Command' %}{% trans 'Success' %}{% trans 'Finished' %}{% trans 'Date start' %}{% trans 'Time' %}{% trans 'Action' %}
+{% endblock %} +{% block custom_foot_js %} + + + +{% endblock %} diff --git a/apps/audits/urls.py b/apps/audits/urls.py index cff9a2c30..37962d9db 100644 --- a/apps/audits/urls.py +++ b/apps/audits/urls.py @@ -10,6 +10,7 @@ urlpatterns = [ url(r'^proxy-log$', views.ProxyLogListView.as_view(), name='proxy-log-list'), url(r'^proxy-log/(?P\d+)$', views.ProxyLogDetailView.as_view(), name='proxy-log-detail'), url(r'^proxy-log/(?P\d+)/commands$', views.ProxyLogCommandsListView.as_view(), name='proxy-log-commands-list'), + url(r'^command-log$', views.CommandLogListView.as_view(), name='command-log-list'), ] diff --git a/apps/audits/views.py b/apps/audits/views.py index ddca25bf3..3c2ecf853 100644 --- a/apps/audits/views.py +++ b/apps/audits/views.py @@ -1,7 +1,7 @@ # ~*~ coding: utf-8 ~*~ # -from django.views.generic import ListView, UpdateView, DeleteView, DetailView +from django.views.generic import ListView, UpdateView, DeleteView, DetailView, TemplateView from django.views.generic.edit import SingleObjectMixin from django.utils.translation import ugettext as _ from django.urls import reverse_lazy @@ -11,8 +11,7 @@ from .models import ProxyLog, CommandLog from .utils import AdminUserRequiredMixin -class ProxyLogListView(ListView): - model = ProxyLog +class ProxyLogListView(TemplateView): template_name = 'audits/proxy_log_list.html' def get_context_data(self, **kwargs): @@ -50,3 +49,15 @@ class ProxyLogCommandsListView(AdminUserRequiredMixin, SingleObjectMixin, ListVi def get_queryset(self): return list(self.object.command_log.all()) + + +class CommandLogListView(AdminUserRequiredMixin, TemplateView): + template_name = 'audits/command_log_list.html' + + def get_context_data(self, **kwargs): + context = { + 'app': 'Audits', + 'action': 'Command log list' + } + kwargs.update(context) + return super(CommandLogListView, self).get_context_data(**kwargs)