perf: session 添加类型

pull/9219/head
ibuler 2 years ago
parent 26fa1f6f08
commit 26794064b5

@ -1,7 +1,9 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
from assets.const import Protocol
from common.drf.fields import LabeledChoiceField
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
from ..models import Session
@ -11,17 +13,25 @@ __all__ = [
]
class SessionType(models.TextChoices):
normal = 'normal', _('Normal')
tunnel = 'tunnel', _('Tunnel')
command = 'command', _('Command')
class SessionSerializer(BulkOrgResourceModelSerializer):
org_id = serializers.CharField(allow_blank=True)
protocol = serializers.ChoiceField(choices=Protocol.choices, label=_("Protocol"))
type = LabeledChoiceField(choices=SessionType.choices, label=_("Type"))
class Meta:
model = Session
fields_mini = ["id"]
fields_small = fields_mini + [
"user", "asset", "user_id", "asset_id", 'account', "protocol",
"login_from", "remote_addr", "is_success",
"is_finished", "has_replay", "date_start", "date_end",
"user", "asset", "user_id", "asset_id", 'account',
"protocol", 'type', "login_from", "remote_addr",
"is_success", "is_finished", "has_replay", "has_command",
"date_start", "date_end", "comment"
]
fields_fk = ["terminal", ]
fields_custom = ["can_replay", "can_join", "can_terminate"]

Loading…
Cancel
Save