mirror of https://github.com/jumpserver/jumpserver
22 lines
627 B
Python
22 lines
627 B
Python
|
# ~*~ coding: utf-8 ~*~
|
||
|
import base64
|
||
|
from rest_framework import serializers
|
||
|
from audits.models import CommandLog
|
||
|
from audits.backends import command_store
|
||
|
|
||
|
|
||
|
class CommandLogSerializer(serializers.ModelSerializer):
|
||
|
"""使用这个类作为基础Command Log Serializer类, 用来序列化"""
|
||
|
|
||
|
class Meta:
|
||
|
model = CommandLog
|
||
|
fields = '__all__'
|
||
|
|
||
|
def save(self):
|
||
|
try:
|
||
|
output = self.validated_data['output']
|
||
|
self.validated_data['output'] = base64.b64decode(output)
|
||
|
except IndexError:
|
||
|
pass
|
||
|
return command_store.save(**dict(self.validated_data))
|