jumpserver/apps/audits/views.py

42 lines
1.3 KiB
Python
Raw Normal View History

2016-10-25 15:23:01 +00:00
# ~*~ coding: utf-8 ~*~
#
from django.views.generic import ListView, UpdateView, DeleteView, DetailView
2016-10-26 11:10:14 +00:00
from django.views.generic.edit import SingleObjectMixin
2016-10-25 15:23:01 +00:00
from django.utils.translation import ugettext as _
from django.urls import reverse_lazy
2016-10-26 11:10:14 +00:00
from django.conf import settings
2016-10-25 15:23:01 +00:00
from .models import ProxyLog, CommandLog
2016-10-26 11:10:14 +00:00
from .utils import AdminUserRequiredMixin
2016-10-25 15:23:01 +00:00
class ProxyLogListView(ListView):
model = ProxyLog
template_name = 'audits/proxy_log_list.html'
def get_context_data(self, **kwargs):
context = super(ProxyLogListView, self).get_context_data(**kwargs)
context.update({'app': _('Audits'), 'action': _('Proxy log list')})
return context
2016-10-26 11:10:14 +00:00
class ProxyLogDetailView(AdminUserRequiredMixin, SingleObjectMixin, ListView):
2016-10-25 15:23:01 +00:00
template_name = 'audits/proxy_log_detail.html'
2016-10-26 11:10:14 +00:00
context_object_name = 'proxy_log'
2016-10-25 15:23:01 +00:00
2016-10-26 11:10:14 +00:00
def get(self, request, *args, **kwargs):
self.object = self.get_object(queryset=ProxyLog.objects.all())
return super(ProxyLogDetailView, self).get(request, *args, **kwargs)
2016-08-08 16:43:11 +00:00
2016-10-26 11:10:14 +00:00
def get_queryset(self):
return list(self.object.command_log.all())
def get_context_data(self, **kwargs):
context = {
'app': 'Audits',
'action': 'Proxy log detail',
}
kwargs.update(context)
return super(ProxyLogDetailView, self).get_context_data(**kwargs)