mirror of https://github.com/jumpserver/jumpserver
perf: 会话列表显示终端名称;修复启动 warning 问题
parent
927ae43af2
commit
62a2a74c27
|
@ -260,7 +260,7 @@ def decrypt_password(value):
|
|||
try:
|
||||
password = aes.decrypt(password_cipher)
|
||||
except UnicodeDecodeError as e:
|
||||
logging.error("Decript password error: {}, {}".format(password_cipher, e))
|
||||
logging.error("Decrypt password error: {}, {}".format(password_cipher, e))
|
||||
return value
|
||||
return password
|
||||
|
||||
|
|
|
@ -306,6 +306,8 @@ FORCE_SCRIPT_NAME = CONFIG.FORCE_SCRIPT_NAME
|
|||
SESSION_COOKIE_SECURE = CONFIG.SESSION_COOKIE_SECURE
|
||||
CSRF_COOKIE_SECURE = CONFIG.CSRF_COOKIE_SECURE
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
|
||||
|
||||
# For Debug toolbar
|
||||
INTERNAL_IPS = ["127.0.0.1"]
|
||||
if DEBUG_DEV:
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import os
|
||||
import tarfile
|
||||
|
||||
from django.db.models import F
|
||||
from django.shortcuts import get_object_or_404, reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.encoding import escape_uri_path
|
||||
|
@ -106,6 +107,11 @@ class SessionViewSet(OrgBulkModelViewSet):
|
|||
response["Content-Disposition"] = disposition
|
||||
return response
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset().prefetch_related('terminal')\
|
||||
.annotate(terminal_display=F('terminal__name'))
|
||||
return queryset
|
||||
|
||||
def filter_queryset(self, queryset):
|
||||
queryset = super().filter_queryset(queryset)
|
||||
# 解决guacamole更新session时并发导致幽灵会话的问题,暂不处理
|
||||
|
|
|
@ -12,6 +12,7 @@ __all__ = [
|
|||
|
||||
class SessionSerializer(BulkOrgResourceModelSerializer):
|
||||
org_id = serializers.CharField(allow_blank=True)
|
||||
terminal_display = serializers.CharField(read_only=True, label=_('Terminal display'))
|
||||
|
||||
class Meta:
|
||||
model = Session
|
||||
|
@ -23,8 +24,8 @@ class SessionSerializer(BulkOrgResourceModelSerializer):
|
|||
"is_success", "is_finished", "has_replay",
|
||||
"date_start", "date_end",
|
||||
]
|
||||
fields_fk = ["terminal",]
|
||||
fields_custom = ["can_replay", "can_join", "can_terminate",]
|
||||
fields_fk = ["terminal", ]
|
||||
fields_custom = ["can_replay", "can_join", "can_terminate", 'terminal_display']
|
||||
fields = fields_small + fields_fk + fields_custom
|
||||
extra_kwargs = {
|
||||
"protocol": {'label': _('Protocol')},
|
||||
|
@ -38,6 +39,7 @@ class SessionSerializer(BulkOrgResourceModelSerializer):
|
|||
'terminal': {'label': _('Terminal')},
|
||||
'is_finished': {'label': _('Is finished')},
|
||||
'can_terminate': {'label': _('Can terminate')},
|
||||
'terminal_display': {'label': _('Terminal display')},
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,7 +47,7 @@ class SessionDisplaySerializer(SessionSerializer):
|
|||
command_amount = serializers.IntegerField(read_only=True, label=_('Command amount'))
|
||||
|
||||
class Meta(SessionSerializer.Meta):
|
||||
fields = SessionSerializer.Meta.fields + ['command_amount']
|
||||
fields = SessionSerializer.Meta.fields + ['command_amount', ]
|
||||
|
||||
|
||||
class ReplaySerializer(serializers.Serializer):
|
||||
|
|
Loading…
Reference in New Issue