You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jumpserver/apps/audits/serializers.py

35 lines
1023 B

8 years ago
# -*- coding: utf-8 -*-
8 years ago
#
from __future__ import absolute_import, unicode_literals
8 years ago
from rest_framework import serializers
8 years ago
from common.utils import timesince
8 years ago
from . import models
8 years ago
class ProxyLogSerializer(serializers.ModelSerializer):
8 years ago
time = serializers.SerializerMethodField()
command_length = serializers.SerializerMethodField()
8 years ago
class Meta:
model = models.ProxyLog
fields = ['id', 'name', 'username', 'hostname', 'ip', 'system_user', 'login_type', 'terminal',
'log_file', 'was_failed', 'is_finished', 'date_start', 'date_finished', 'time',
'command_length', "commands_dict"]
8 years ago
@staticmethod
def get_time(obj):
8 years ago
if not obj.is_finished:
return ''
else:
return timesince(obj.date_start, since=obj.date_finished)
8 years ago
@staticmethod
def get_command_length(obj):
return len(obj.commands.all())
8 years ago
class CommandLogSerializer(serializers.ModelSerializer):
class Meta:
model = models.CommandLog