perf: BaseManager email subject translate

This commit is contained in:
wangruidong 2025-03-12 19:02:41 +08:00 committed by w940853815
parent 30e64ecfc1
commit 28f85a0186
2 changed files with 50 additions and 45 deletions

View File

@ -3,10 +3,10 @@ import json
import logging
import os
import shutil
import time
from collections import defaultdict
from socket import gethostname
import time
import yaml
from django.conf import settings
from django.template.loader import render_to_string
@ -137,24 +137,15 @@ class BaseManager:
raise NotImplementedError
def get_report_subject(self):
return f"Automation {self.execution.id} finished"
return _("Task: {} finished").format(self.execution.automation.name)
def get_report_context(self):
logo = self.get_file_content("static/img/JumpServer_white_logo.svg")
return {
"execution": self.execution,
"summary": self.execution.summary,
"result": self.execution.result,
"logo": logo,
"result": self.execution.result
}
@staticmethod
def get_file_content(path):
file_path = os.path.join(settings.BASE_DIR, path)
with open(file_path, "r", encoding="utf-8") as f:
file_content = f.read()
return file_content
def send_report_if_need(self):
recipients = self.execution.recipients
if not recipients:

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: JumpServer 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-12 17:42+0800\n"
"POT-Creation-Date: 2025-03-12 18:56+0800\n"
"PO-Revision-Date: 2021-05-20 10:54+0800\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: JumpServer team<ibuler@qq.com>\n"
@ -136,6 +136,8 @@ msgstr ">>> 开始执行测试网关账号可连接性任务"
#: users/templates/users/_msg_user_created.html:13
#: users/templates/users/user_password_verify.html:18
#: xpack/plugins/cloud/serializers/account_attrs.py:28
#: xpack/plugins/cloud/serializers/account_attrs.py:90
#: xpack/plugins/cloud/serializers/account_attrs.py:97
msgid "Password"
msgstr "密码"
@ -865,6 +867,8 @@ msgstr "重复密码"
#: users/forms/profile.py:117 users/models/user/__init__.py:59
#: users/templates/users/_msg_user_created.html:12
#: xpack/plugins/cloud/serializers/account_attrs.py:26
#: xpack/plugins/cloud/serializers/account_attrs.py:88
#: xpack/plugins/cloud/serializers/account_attrs.py:95
msgid "Username"
msgstr "用户名"
@ -1895,8 +1899,8 @@ msgid ""
"10.1.1.1-10.1.1.20, 2001:db8:2de::e13, 2001:db8:1a:1110::/64 (Domain name "
"support)"
msgstr ""
"* 表示匹配所有。例如: 192.168.10.1, 192.168.1.0/24, 10.1.1.1-10.1.1.20, 2001:"
"db8:2de::e13, 2001:db8:1a:1110::/64 (支持网域)"
"* 表示匹配所有。例如: 192.168.10.1, 192.168.1.0/24, 10.1.1.1-10.1.1.20, "
"2001:db8:2de::e13, 2001:db8:1a:1110::/64 (支持网域)"
#: acls/serializers/base.py:41 assets/serializers/asset/host.py:19
msgid "IP/Host"
@ -1924,8 +1928,8 @@ msgid ""
"With * indicating a match all. Such as: 192.168.10.1, 192.168.1.0/24, "
"10.1.1.1-10.1.1.20, 2001:db8:2de::e13, 2001:db8:1a:1110::/64 "
msgstr ""
"* 表示匹配所有。例如: 192.168.10.1, 192.168.1.0/24, 10.1.1.1-10.1.1.20, 2001:"
"db8:2de::e13, 2001:db8:1a:1110::/64"
"* 表示匹配所有。例如: 192.168.10.1, 192.168.1.0/24, 10.1.1.1-10.1.1.20, "
"2001:db8:2de::e13, 2001:db8:1a:1110::/64"
#: acls/serializers/rules/rules.py:33
#: authentication/templates/authentication/_msg_oauth_bind.html:12
@ -2025,28 +2029,32 @@ msgstr "同级别节点名字不能重复"
msgid "App Assets"
msgstr "资产管理"
#: assets/automations/base/manager.py:347
#: assets/automations/base/manager.py:140
msgid "Task: {} finished"
msgstr "任务:{} 完成"
#: assets/automations/base/manager.py:338
msgid " - Platform {} ansible disabled"
msgstr " - 平台 {} Ansible 已禁用, 无法执行任务"
#: assets/automations/base/manager.py:530
#: assets/automations/base/manager.py:521
msgid ">>> Task preparation phase"
msgstr ">>> 任务准备阶段"
#: assets/automations/base/manager.py:534
#: assets/automations/base/manager.py:525
#, python-brace-format
msgid ">>> Executing tasks in batches, total {runner_count}"
msgstr ">>> 分次执行任务,总共 {runner_count}"
#: assets/automations/base/manager.py:539
#: assets/automations/base/manager.py:530
msgid ">>> Start executing tasks"
msgstr ">>> 开始执行任务"
#: assets/automations/base/manager.py:541
#: assets/automations/base/manager.py:532
msgid ">>> No tasks need to be executed"
msgstr ">>> 没有需要执行的任务"
#: assets/automations/base/manager.py:545
#: assets/automations/base/manager.py:536
#, python-brace-format
msgid ">>> Begin executing batch {index} of tasks"
msgstr ">>> 开始执行第 {index} 批任务"
@ -2144,7 +2152,8 @@ msgstr "云服务"
msgid "Web"
msgstr "Web"
#: assets/const/category.py:15 common/sdk/sms/endpoint.py:20
#: assets/const/category.py:15 common/sdk/sms/custom_file.py:47
#: common/sdk/sms/endpoint.py:20
msgid "Custom type"
msgstr "自定义类型"
@ -2836,7 +2845,7 @@ msgstr "端口超出范围 (0-65535)"
msgid "Protocol is required: {}"
msgstr "协议是必填的: {}"
#: assets/serializers/asset/common.py:350
#: assets/serializers/asset/common.py:350 labels/api.py:107
msgid "Invalid data"
msgstr "无效的数据"
@ -4940,6 +4949,10 @@ msgstr "自定义短信文件无效"
msgid "SMS sending failed[%s]: %s"
msgstr "短信发送失败[%s]: %s"
#: common/sdk/sms/custom_file.py:47 common/serializers/common.py:98
msgid "File"
msgstr "文件"
#: common/sdk/sms/endpoint.py:16
msgid "Alibaba cloud"
msgstr "阿里云"
@ -4984,10 +4997,6 @@ msgstr "请在 {} 秒后发送"
msgid "Children"
msgstr "节点"
#: common/serializers/common.py:98
msgid "File"
msgstr "文件"
#: common/serializers/fields.py:139
msgid "Invalid data type"
msgstr "无效的数据"
@ -5108,6 +5117,10 @@ msgstr "你的账号已创建成功"
msgid "JumpServer - An open-source PAM"
msgstr "JumpServer 开源堡垒机"
#: jumpserver/context_processor.py:28
msgid "FIT2CLOUD"
msgstr ""
#: jumpserver/views/celery_flower.py:22
msgid "<h1>Flower service unavailable, check it</h1>"
msgstr "Flower 服务不可用,请检查"
@ -7109,7 +7122,7 @@ msgstr "租户 ID"
#: settings/serializers/feature.py:110 terminal/serializers/storage.py:68
#: xpack/plugins/cloud/manager.py:111 xpack/plugins/cloud/manager.py:116
#: xpack/plugins/cloud/models.py:287
#: xpack/plugins/cloud/manager.py:153 xpack/plugins/cloud/models.py:287
msgid "Region"
msgstr "地域"
@ -8056,7 +8069,7 @@ msgstr "会话不存在: {}"
msgid "Session is finished or the protocol not supported"
msgstr "会话已经完成或协议不支持"
#: terminal/api/session/session.py:345
#: terminal/api/session/session.py:345 tickets/api/ticket.py:140
msgid "User does not have permission"
msgstr "用户没有权限"
@ -8600,9 +8613,9 @@ msgid ""
"days. <a href=\"https://learn.microsoft.com/en-us/windows-server/remote/"
"remote-desktop-services/rds-client-access-license\">Detail</a>"
msgstr ""
"如果不存在RDS 将处于试用模式,试用期为 120 天。<a href='https://learn."
"microsoft.com/en-us/windows-server/remote/remote-desktop-services/rds-client-"
"access-license'>详情</a>"
"如果不存在RDS 将处于试用模式,试用期为 120 天。<a href='https://"
"learn.microsoft.com/en-us/windows-server/remote/remote-desktop-services/rds-"
"client-access-license'>详情</a>"
#: terminal/serializers/applet_host.py:55
msgid "RDS License Server"
@ -8836,8 +8849,8 @@ msgid ""
"If there are multiple hosts, use a comma (,) to separate them. <br>(For "
"example: http://www.jumpserver.a.com:9100, http://www.jumpserver.b.com:9100)"
msgstr ""
"如果有多个主机,请用逗号 (,) 分隔它们。<br>例如http://www.jumpserver.a."
"com:9100http://www.jumpserver.b.com:9100"
"如果有多个主机,请用逗号 (,) 分隔它们。<br>例如http://"
"www.jumpserver.a.com:9100http://www.jumpserver.b.com:9100"
#: terminal/serializers/storage.py:199
msgid "Index by date"
@ -10450,6 +10463,10 @@ msgstr "同步地区"
msgid "Get instances of region \"%s\" error, error: %s"
msgstr "获取区域 \"%s\" 的实例错误,错误:%s"
#: xpack/plugins/cloud/manager.py:153 xpack/plugins/cloud/models.py:284
msgid "Instance"
msgstr "实例"
#: xpack/plugins/cloud/manager.py:179
#, python-format
msgid "Failed to synchronize the instance \"%s\""
@ -10592,10 +10609,6 @@ msgstr "同步任务"
msgid "Sync instance task history"
msgstr "同步实例任务历史"
#: xpack/plugins/cloud/models.py:284
msgid "Instance"
msgstr "实例"
#: xpack/plugins/cloud/models.py:301
msgid "Sync instance detail"
msgstr "同步实例详情"
@ -10900,6 +10913,12 @@ msgstr "订阅 ID"
msgid "Auto node classification"
msgstr "自动节点分类"
#: xpack/plugins/cloud/serializers/account_attrs.py:93
#, fuzzy
#| msgid "Container name"
msgid "domain_name"
msgstr "容器名称"
#: xpack/plugins/cloud/serializers/account_attrs.py:99
#: xpack/plugins/cloud/serializers/account_attrs.py:103
#: xpack/plugins/cloud/serializers/account_attrs.py:127
@ -11095,8 +11114,3 @@ msgstr "许可证无效"
#~ msgid ""
#~ "The following is a summary of account push tasks, please read and process"
#~ msgstr "以下是账号推送任务的汇总,请阅读并处理"
#, fuzzy
#~| msgid "Container name"
#~ msgid "domain_name"
#~ msgstr "容器名称"