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