perf: 优化会话分享url的构造

pull/11111/head
fangfang.dong 2023-07-27 12:52:33 +08:00 committed by Bryan
parent 7a37f91964
commit 1239ffd4c8
6 changed files with 61 additions and 57 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-26 19:15+0800\n" "POT-Creation-Date: 2023-07-27 11:11+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -316,7 +316,7 @@ msgid "Trigger mode"
msgstr "トリガーモード" msgstr "トリガーモード"
#: accounts/models/automations/backup_account.py:97 audits/models.py:194 #: accounts/models/automations/backup_account.py:97 audits/models.py:194
#: terminal/models/session/sharing.py:119 xpack/plugins/cloud/models.py:168 #: terminal/models/session/sharing.py:117 xpack/plugins/cloud/models.py:168
msgid "Reason" msgid "Reason"
msgstr "理由" msgstr "理由"
@ -657,7 +657,7 @@ msgstr "ID"
#: perms/api/user_permission/mixin.py:55 perms/models/asset_permission.py:58 #: perms/api/user_permission/mixin.py:55 perms/models/asset_permission.py:58
#: perms/serializers/permission.py:30 rbac/builtin.py:123 #: perms/serializers/permission.py:30 rbac/builtin.py:123
#: rbac/models/rolebinding.py:49 terminal/backends/command/models.py:16 #: rbac/models/rolebinding.py:49 terminal/backends/command/models.py:16
#: terminal/models/session/session.py:29 terminal/models/session/sharing.py:35 #: terminal/models/session/session.py:29 terminal/models/session/sharing.py:33
#: terminal/notifications.py:156 terminal/notifications.py:205 #: terminal/notifications.py:156 terminal/notifications.py:205
#: terminal/serializers/command.py:16 #: terminal/serializers/command.py:16
#: terminal/templates/terminal/_msg_command_warning.html:6 #: terminal/templates/terminal/_msg_command_warning.html:6
@ -748,7 +748,7 @@ msgstr "自動タスク実行履歴"
#: accounts/serializers/automations/change_secret.py:155 audits/const.py:53 #: accounts/serializers/automations/change_secret.py:155 audits/const.py:53
#: audits/models.py:59 audits/signal_handlers/activity_log.py:33 #: audits/models.py:59 audits/signal_handlers/activity_log.py:33
#: common/const/choices.py:18 ops/const.py:56 ops/serializers/celery.py:40 #: common/const/choices.py:18 ops/const.py:56 ops/serializers/celery.py:40
#: terminal/const.py:76 terminal/models/session/sharing.py:115 #: terminal/const.py:76 terminal/models/session/sharing.py:113
#: tickets/views/approve.py:115 #: tickets/views/approve.py:115
msgid "Success" msgid "Success"
msgstr "成功" msgstr "成功"
@ -832,7 +832,7 @@ msgstr "レビュー担当者"
#: acls/models/base.py:43 authentication/models/access_key.py:17 #: acls/models/base.py:43 authentication/models/access_key.py:17
#: authentication/models/connection_token.py:53 #: authentication/models/connection_token.py:53
#: authentication/templates/authentication/_access_key_modal.html:32 #: authentication/templates/authentication/_access_key_modal.html:32
#: perms/models/asset_permission.py:76 terminal/models/session/sharing.py:30 #: perms/models/asset_permission.py:76 terminal/models/session/sharing.py:28
#: tickets/const.py:37 #: tickets/const.py:37
msgid "Active" msgid "Active"
msgstr "アクティブ" msgstr "アクティブ"
@ -2061,7 +2061,7 @@ msgid "Job audit log"
msgstr "ジョブ監査ログ" msgstr "ジョブ監査ログ"
#: audits/models.py:51 audits/models.py:95 audits/models.py:166 #: audits/models.py:51 audits/models.py:95 audits/models.py:166
#: terminal/models/session/session.py:38 terminal/models/session/sharing.py:107 #: terminal/models/session/session.py:38 terminal/models/session/sharing.py:105
msgid "Remote addr" msgid "Remote addr"
msgstr "リモートaddr" msgstr "リモートaddr"
@ -2078,8 +2078,8 @@ msgid "File"
msgstr "書類" msgstr "書類"
#: audits/models.py:62 terminal/backends/command/models.py:21 #: audits/models.py:62 terminal/backends/command/models.py:21
#: terminal/models/session/replay.py:9 terminal/models/session/sharing.py:21 #: terminal/models/session/replay.py:9 terminal/models/session/sharing.py:19
#: terminal/models/session/sharing.py:89 #: terminal/models/session/sharing.py:87
#: terminal/templates/terminal/_msg_command_alert.html:10 #: terminal/templates/terminal/_msg_command_alert.html:10
#: terminal/templates/terminal/_msg_command_warning.html:17 #: terminal/templates/terminal/_msg_command_warning.html:17
#: tickets/models/ticket/command_confirm.py:15 #: tickets/models/ticket/command_confirm.py:15
@ -2940,7 +2940,7 @@ msgid "request new one"
msgstr "新しいものを要求する" msgstr "新しいものを要求する"
#: authentication/templates/authentication/_msg_reset_password_code.html:12 #: authentication/templates/authentication/_msg_reset_password_code.html:12
#: terminal/models/session/sharing.py:28 terminal/models/session/sharing.py:91 #: terminal/models/session/sharing.py:26 terminal/models/session/sharing.py:89
#: terminal/templates/terminal/_msg_session_sharing.html:12 #: terminal/templates/terminal/_msg_session_sharing.html:12
#: users/forms/profile.py:107 users/templates/users/forgot_password.html:66 #: users/forms/profile.py:107 users/templates/users/forgot_password.html:66
msgid "Verify code" msgid "Verify code"
@ -3689,7 +3689,7 @@ msgstr "アルグ"
#: ops/models/adhoc.py:25 ops/models/base.py:16 ops/models/base.py:53 #: ops/models/adhoc.py:25 ops/models/base.py:16 ops/models/base.py:53
#: ops/models/job.py:106 ops/models/job.py:192 ops/models/playbook.py:25 #: ops/models/job.py:106 ops/models/job.py:192 ops/models/playbook.py:25
#: terminal/models/session/sharing.py:26 #: terminal/models/session/sharing.py:24
msgid "Creator" msgid "Creator"
msgstr "作成者" msgstr "作成者"
@ -3730,7 +3730,7 @@ msgstr "タスクモニターを表示できます"
msgid "Kwargs" msgid "Kwargs"
msgstr "クワーグ" msgstr "クワーグ"
#: ops/models/celery.py:61 terminal/models/session/sharing.py:122 #: ops/models/celery.py:61 terminal/models/session/sharing.py:120
#: tickets/const.py:25 #: tickets/const.py:25
msgid "Finished" msgid "Finished"
msgstr "終了" msgstr "終了"
@ -6000,7 +6000,7 @@ msgstr "セッション再生をダウンロードできます"
msgid "Account id" msgid "Account id"
msgstr "アカウント ID" msgstr "アカウント ID"
#: terminal/models/session/session.py:36 terminal/models/session/sharing.py:112 #: terminal/models/session/session.py:36 terminal/models/session/sharing.py:110
msgid "Login from" msgid "Login from"
msgstr "ログイン元" msgstr "ログイン元"
@ -6032,61 +6032,61 @@ msgstr "セッションを終了できます"
msgid "Can validate session action perm" msgid "Can validate session action perm"
msgstr "セッションアクションのパーマを検証できます" msgstr "セッションアクションのパーマを検証できます"
#: terminal/models/session/sharing.py:33 #: terminal/models/session/sharing.py:31
msgid "Expired time (min)" msgid "Expired time (min)"
msgstr "期限切れ時間 (分)" msgstr "期限切れ時間 (分)"
#: terminal/models/session/sharing.py:37 terminal/serializers/sharing.py:20 #: terminal/models/session/sharing.py:35 terminal/serializers/sharing.py:20
#: terminal/serializers/sharing.py:52 #: terminal/serializers/sharing.py:52
msgid "Action permission" msgid "Action permission"
msgstr "アクションパーミッション" msgstr "アクションパーミッション"
#: terminal/models/session/sharing.py:39 #: terminal/models/session/sharing.py:37
msgid "Origin" msgid "Origin"
msgstr "" msgstr "ソース"
#: terminal/models/session/sharing.py:43 terminal/models/session/sharing.py:94 #: terminal/models/session/sharing.py:41 terminal/models/session/sharing.py:92
#: terminal/notifications.py:261 #: terminal/notifications.py:261
msgid "Session sharing" msgid "Session sharing"
msgstr "セッション共有" msgstr "セッション共有"
#: terminal/models/session/sharing.py:45 #: terminal/models/session/sharing.py:43
msgid "Can add super session sharing" msgid "Can add super session sharing"
msgstr "スーパーセッション共有を追加できます" msgstr "スーパーセッション共有を追加できます"
#: terminal/models/session/sharing.py:77 #: terminal/models/session/sharing.py:75
msgid "Link not active" msgid "Link not active"
msgstr "リンクがアクティブでない" msgstr "リンクがアクティブでない"
#: terminal/models/session/sharing.py:79 #: terminal/models/session/sharing.py:77
msgid "Link expired" msgid "Link expired"
msgstr "リンク期限切れ" msgstr "リンク期限切れ"
#: terminal/models/session/sharing.py:81 #: terminal/models/session/sharing.py:79
msgid "User not allowed to join" msgid "User not allowed to join"
msgstr "ユーザーはセッションに参加できません" msgstr "ユーザーはセッションに参加できません"
#: terminal/models/session/sharing.py:98 terminal/serializers/sharing.py:71 #: terminal/models/session/sharing.py:96 terminal/serializers/sharing.py:71
msgid "Joiner" msgid "Joiner"
msgstr "ジョイナー" msgstr "ジョイナー"
#: terminal/models/session/sharing.py:101 #: terminal/models/session/sharing.py:99
msgid "Date joined" msgid "Date joined"
msgstr "参加日" msgstr "参加日"
#: terminal/models/session/sharing.py:104 #: terminal/models/session/sharing.py:102
msgid "Date left" msgid "Date left"
msgstr "日付が残っています" msgstr "日付が残っています"
#: terminal/models/session/sharing.py:127 #: terminal/models/session/sharing.py:125
msgid "Session join record" msgid "Session join record"
msgstr "セッション参加記録" msgstr "セッション参加記録"
#: terminal/models/session/sharing.py:143 #: terminal/models/session/sharing.py:141
msgid "Invalid verification code" msgid "Invalid verification code"
msgstr "検証コードが無効" msgstr "検証コードが無効"
#: terminal/models/session/sharing.py:150 #: terminal/models/session/sharing.py:148
msgid "You have already joined this session" msgid "You have already joined this session"
msgstr "すでにこのセッションに参加しています" msgstr "すでにこのセッションに参加しています"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: JumpServer 0.3.3\n" "Project-Id-Version: JumpServer 0.3.3\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-26 19:14+0800\n" "POT-Creation-Date: 2023-07-27 11:11+0800\n"
"PO-Revision-Date: 2021-05-20 10:54+0800\n" "PO-Revision-Date: 2021-05-20 10:54+0800\n"
"Last-Translator: ibuler <ibuler@qq.com>\n" "Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: JumpServer team<ibuler@qq.com>\n" "Language-Team: JumpServer team<ibuler@qq.com>\n"
@ -315,7 +315,7 @@ msgid "Trigger mode"
msgstr "触发模式" msgstr "触发模式"
#: accounts/models/automations/backup_account.py:97 audits/models.py:194 #: accounts/models/automations/backup_account.py:97 audits/models.py:194
#: terminal/models/session/sharing.py:119 xpack/plugins/cloud/models.py:168 #: terminal/models/session/sharing.py:117 xpack/plugins/cloud/models.py:168
msgid "Reason" msgid "Reason"
msgstr "原因" msgstr "原因"
@ -653,7 +653,7 @@ msgstr "ID"
#: perms/api/user_permission/mixin.py:55 perms/models/asset_permission.py:58 #: perms/api/user_permission/mixin.py:55 perms/models/asset_permission.py:58
#: perms/serializers/permission.py:30 rbac/builtin.py:123 #: perms/serializers/permission.py:30 rbac/builtin.py:123
#: rbac/models/rolebinding.py:49 terminal/backends/command/models.py:16 #: rbac/models/rolebinding.py:49 terminal/backends/command/models.py:16
#: terminal/models/session/session.py:29 terminal/models/session/sharing.py:35 #: terminal/models/session/session.py:29 terminal/models/session/sharing.py:33
#: terminal/notifications.py:156 terminal/notifications.py:205 #: terminal/notifications.py:156 terminal/notifications.py:205
#: terminal/serializers/command.py:16 #: terminal/serializers/command.py:16
#: terminal/templates/terminal/_msg_command_warning.html:6 #: terminal/templates/terminal/_msg_command_warning.html:6
@ -744,7 +744,7 @@ msgstr "自动化任务执行历史"
#: accounts/serializers/automations/change_secret.py:155 audits/const.py:53 #: accounts/serializers/automations/change_secret.py:155 audits/const.py:53
#: audits/models.py:59 audits/signal_handlers/activity_log.py:33 #: audits/models.py:59 audits/signal_handlers/activity_log.py:33
#: common/const/choices.py:18 ops/const.py:56 ops/serializers/celery.py:40 #: common/const/choices.py:18 ops/const.py:56 ops/serializers/celery.py:40
#: terminal/const.py:76 terminal/models/session/sharing.py:115 #: terminal/const.py:76 terminal/models/session/sharing.py:113
#: tickets/views/approve.py:115 #: tickets/views/approve.py:115
msgid "Success" msgid "Success"
msgstr "成功" msgstr "成功"
@ -828,7 +828,7 @@ msgstr "审批人"
#: acls/models/base.py:43 authentication/models/access_key.py:17 #: acls/models/base.py:43 authentication/models/access_key.py:17
#: authentication/models/connection_token.py:53 #: authentication/models/connection_token.py:53
#: authentication/templates/authentication/_access_key_modal.html:32 #: authentication/templates/authentication/_access_key_modal.html:32
#: perms/models/asset_permission.py:76 terminal/models/session/sharing.py:30 #: perms/models/asset_permission.py:76 terminal/models/session/sharing.py:28
#: tickets/const.py:37 #: tickets/const.py:37
msgid "Active" msgid "Active"
msgstr "激活中" msgstr "激活中"
@ -2045,7 +2045,7 @@ msgid "Job audit log"
msgstr "作业审计日志" msgstr "作业审计日志"
#: audits/models.py:51 audits/models.py:95 audits/models.py:166 #: audits/models.py:51 audits/models.py:95 audits/models.py:166
#: terminal/models/session/session.py:38 terminal/models/session/sharing.py:107 #: terminal/models/session/session.py:38 terminal/models/session/sharing.py:105
msgid "Remote addr" msgid "Remote addr"
msgstr "远端地址" msgstr "远端地址"
@ -2062,8 +2062,8 @@ msgid "File"
msgstr "文件" msgstr "文件"
#: audits/models.py:62 terminal/backends/command/models.py:21 #: audits/models.py:62 terminal/backends/command/models.py:21
#: terminal/models/session/replay.py:9 terminal/models/session/sharing.py:21 #: terminal/models/session/replay.py:9 terminal/models/session/sharing.py:19
#: terminal/models/session/sharing.py:89 #: terminal/models/session/sharing.py:87
#: terminal/templates/terminal/_msg_command_alert.html:10 #: terminal/templates/terminal/_msg_command_alert.html:10
#: terminal/templates/terminal/_msg_command_warning.html:17 #: terminal/templates/terminal/_msg_command_warning.html:17
#: tickets/models/ticket/command_confirm.py:15 #: tickets/models/ticket/command_confirm.py:15
@ -2904,7 +2904,7 @@ msgid "request new one"
msgstr "重新申请" msgstr "重新申请"
#: authentication/templates/authentication/_msg_reset_password_code.html:12 #: authentication/templates/authentication/_msg_reset_password_code.html:12
#: terminal/models/session/sharing.py:28 terminal/models/session/sharing.py:91 #: terminal/models/session/sharing.py:26 terminal/models/session/sharing.py:89
#: terminal/templates/terminal/_msg_session_sharing.html:12 #: terminal/templates/terminal/_msg_session_sharing.html:12
#: users/forms/profile.py:107 users/templates/users/forgot_password.html:66 #: users/forms/profile.py:107 users/templates/users/forgot_password.html:66
msgid "Verify code" msgid "Verify code"
@ -3642,7 +3642,7 @@ msgstr "参数"
#: ops/models/adhoc.py:25 ops/models/base.py:16 ops/models/base.py:53 #: ops/models/adhoc.py:25 ops/models/base.py:16 ops/models/base.py:53
#: ops/models/job.py:106 ops/models/job.py:192 ops/models/playbook.py:25 #: ops/models/job.py:106 ops/models/job.py:192 ops/models/playbook.py:25
#: terminal/models/session/sharing.py:26 #: terminal/models/session/sharing.py:24
msgid "Creator" msgid "Creator"
msgstr "创建者" msgstr "创建者"
@ -3683,7 +3683,7 @@ msgstr "可以查看任务监控"
msgid "Kwargs" msgid "Kwargs"
msgstr "其它参数" msgstr "其它参数"
#: ops/models/celery.py:61 terminal/models/session/sharing.py:122 #: ops/models/celery.py:61 terminal/models/session/sharing.py:120
#: tickets/const.py:25 #: tickets/const.py:25
msgid "Finished" msgid "Finished"
msgstr "结束" msgstr "结束"
@ -5913,7 +5913,7 @@ msgstr "可以下载会话录像"
msgid "Account id" msgid "Account id"
msgstr "账号 ID" msgstr "账号 ID"
#: terminal/models/session/session.py:36 terminal/models/session/sharing.py:112 #: terminal/models/session/session.py:36 terminal/models/session/sharing.py:110
msgid "Login from" msgid "Login from"
msgstr "登录来源" msgstr "登录来源"
@ -5945,61 +5945,61 @@ msgstr "可以终断会话"
msgid "Can validate session action perm" msgid "Can validate session action perm"
msgstr "可以验证会话动作权限" msgstr "可以验证会话动作权限"
#: terminal/models/session/sharing.py:33 #: terminal/models/session/sharing.py:31
msgid "Expired time (min)" msgid "Expired time (min)"
msgstr "过期时间 (分)" msgstr "过期时间 (分)"
#: terminal/models/session/sharing.py:37 terminal/serializers/sharing.py:20 #: terminal/models/session/sharing.py:35 terminal/serializers/sharing.py:20
#: terminal/serializers/sharing.py:52 #: terminal/serializers/sharing.py:52
msgid "Action permission" msgid "Action permission"
msgstr "操作权限" msgstr "操作权限"
#: terminal/models/session/sharing.py:39 #: terminal/models/session/sharing.py:37
msgid "Origin" msgid "Origin"
msgstr "" msgstr "来源"
#: terminal/models/session/sharing.py:43 terminal/models/session/sharing.py:94 #: terminal/models/session/sharing.py:41 terminal/models/session/sharing.py:92
#: terminal/notifications.py:261 #: terminal/notifications.py:261
msgid "Session sharing" msgid "Session sharing"
msgstr "会话分享" msgstr "会话分享"
#: terminal/models/session/sharing.py:45 #: terminal/models/session/sharing.py:43
msgid "Can add super session sharing" msgid "Can add super session sharing"
msgstr "可以创建超级会话分享" msgstr "可以创建超级会话分享"
#: terminal/models/session/sharing.py:77 #: terminal/models/session/sharing.py:75
msgid "Link not active" msgid "Link not active"
msgstr "链接失效" msgstr "链接失效"
#: terminal/models/session/sharing.py:79 #: terminal/models/session/sharing.py:77
msgid "Link expired" msgid "Link expired"
msgstr "链接过期" msgstr "链接过期"
#: terminal/models/session/sharing.py:81 #: terminal/models/session/sharing.py:79
msgid "User not allowed to join" msgid "User not allowed to join"
msgstr "该用户无权加入会话" msgstr "该用户无权加入会话"
#: terminal/models/session/sharing.py:98 terminal/serializers/sharing.py:71 #: terminal/models/session/sharing.py:96 terminal/serializers/sharing.py:71
msgid "Joiner" msgid "Joiner"
msgstr "加入者" msgstr "加入者"
#: terminal/models/session/sharing.py:101 #: terminal/models/session/sharing.py:99
msgid "Date joined" msgid "Date joined"
msgstr "加入日期" msgstr "加入日期"
#: terminal/models/session/sharing.py:104 #: terminal/models/session/sharing.py:102
msgid "Date left" msgid "Date left"
msgstr "结束日期" msgstr "结束日期"
#: terminal/models/session/sharing.py:127 #: terminal/models/session/sharing.py:125
msgid "Session join record" msgid "Session join record"
msgstr "会话加入记录" msgstr "会话加入记录"
#: terminal/models/session/sharing.py:143 #: terminal/models/session/sharing.py:141
msgid "Invalid verification code" msgid "Invalid verification code"
msgstr "验证码不正确" msgstr "验证码不正确"
#: terminal/models/session/sharing.py:150 #: terminal/models/session/sharing.py:148
msgid "You have already joined this session" msgid "You have already joined this session"
msgstr "您已经加入过此会话" msgstr "您已经加入过此会话"

View File

@ -46,6 +46,10 @@ class SessionSharing(JMSBaseModel, OrgModelMixin):
def __str__(self): def __str__(self):
return 'Creator: {}'.format(self.creator) return 'Creator: {}'.format(self.creator)
@cached_property
def url(self):
return '%s/koko/share/%s/' % (self.origin, self.id)
@cached_property @cached_property
def users_display(self): def users_display(self):
if not self.users: if not self.users:

View File

@ -270,7 +270,7 @@ class SessionSharingMessage(UserMessage):
'asset': instance.session.asset, 'asset': instance.session.asset,
'created_by': instance.created_by, 'created_by': instance.created_by,
'account': instance.session.account, 'account': instance.session.account,
'session_url': '%s/koko/share/%s/' % (instance.origin, instance.id), 'url': instance.url,
'verify_code': instance.verify_code, 'verify_code': instance.verify_code,
'org': instance.org_name, 'org': instance.org_name,
} }

View File

@ -26,7 +26,7 @@ class SessionSharingSerializer(OrgResourceModelSerializerMixin):
fields_small = fields_mini + [ fields_small = fields_mini + [
'verify_code', 'is_active', 'expired_time', 'created_by', 'verify_code', 'is_active', 'expired_time', 'created_by',
'date_created', 'date_updated', 'users', 'users_display', 'date_created', 'date_updated', 'users', 'users_display',
'action_permission', 'origin', 'action_permission', 'origin', 'url',
] ]
fields_fk = ['session', 'creator'] fields_fk = ['session', 'creator']
fields = fields_small + fields_fk fields = fields_small + fields_fk

View File

@ -7,7 +7,7 @@
<br/> <br/>
<b>{% trans 'Account' %}: </b> <span>{{ account }}</span> <b>{% trans 'Account' %}: </b> <span>{{ account }}</span>
<br/> <br/>
<b>{% trans 'Session sharing URL' %}: </b><a href="{{ session_url }}" target="_blank">{% trans 'View' %}</a> <b>{% trans 'Session sharing URL' %}: </b><a href="{{ url }}" target="_blank">{% trans 'View' %}</a>
<br/> <br/>
<b>{% trans 'Verify code' %}: </b> <span>{{ verify_code }}</span> <b>{% trans 'Verify code' %}: </b> <span>{{ verify_code }}</span>
<br/> <br/>