From 6a1c5aba12e3bd5768ffcb109dc86aaeedaef58f Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 7 Dec 2022 17:24:30 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0095_auto_20220407_1726.py | 3 +- apps/assets/models/platform.py | 5 +- apps/assets/serializers/platform.py | 3 +- apps/locale/ja/LC_MESSAGES/django.po | 3 - apps/locale/zh/LC_MESSAGES/django.po | 363 +++++++----------- apps/orgs/mixins/models.py | 8 +- apps/orgs/models.py | 4 +- apps/orgs/signal_handlers/common.py | 1 + 8 files changed, 140 insertions(+), 250 deletions(-) diff --git a/apps/assets/migrations/0095_auto_20220407_1726.py b/apps/assets/migrations/0095_auto_20220407_1726.py index c11517a35..9d9baf42c 100644 --- a/apps/assets/migrations/0095_auto_20220407_1726.py +++ b/apps/assets/migrations/0095_auto_20220407_1726.py @@ -12,7 +12,6 @@ def migrate_platform_type_to_lower(apps, *args): class Migration(migrations.Migration): - dependencies = [ ('assets', '0094_auto_20220402_1736'), ] @@ -51,7 +50,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='platform', name='su_method', - field=models.CharField(blank=True, max_length=32, null=True, verbose_name='SU method'), + field=models.CharField(blank=True, max_length=32, null=True, verbose_name='Su method'), ), migrations.RunPython(migrate_platform_type_to_lower) ] diff --git a/apps/assets/models/platform.py b/apps/assets/models/platform.py index 64aeb2da3..a4e4ac26b 100644 --- a/apps/assets/models/platform.py +++ b/apps/assets/models/platform.py @@ -2,9 +2,8 @@ from django.db import models from django.utils.translation import gettext_lazy as _ from assets.const import AllTypes -from common.db.fields import JsonDictTextField - from assets.const import Protocol +from common.db.fields import JsonDictTextField __all__ = ['Platform', 'PlatformProtocol', 'PlatformAutomation'] @@ -83,7 +82,7 @@ class Platform(models.Model): protocols_enabled = models.BooleanField(default=True, verbose_name=_("Protocols enabled")) # 账号有关的 su_enabled = models.BooleanField(default=False, verbose_name=_("Su enabled")) - su_method = models.CharField(max_length=32, blank=True, null=True, verbose_name=_("SU method")) + su_method = models.CharField(max_length=32, blank=True, null=True, verbose_name=_("Su method")) automation = models.OneToOneField(PlatformAutomation, on_delete=models.CASCADE, related_name='platform', blank=True, null=True, verbose_name=_("Automation")) diff --git a/apps/assets/serializers/platform.py b/apps/assets/serializers/platform.py index ccb536bb2..6f7458543 100644 --- a/apps/assets/serializers/platform.py +++ b/apps/assets/serializers/platform.py @@ -25,7 +25,7 @@ class ProtocolSettingSerializer(serializers.Serializer): sftp_home = serializers.CharField(default="/tmp", label=_("SFTP home")) # HTTP - auto_fill = serializers.BooleanField(default=False, label=_("Auto fill")) + autofile = serializers.BooleanField(default=False, label=_("Autofill")) username_selector = serializers.CharField( default="", allow_blank=True, label=_("Username selector") ) @@ -38,7 +38,6 @@ class ProtocolSettingSerializer(serializers.Serializer): class PlatformAutomationSerializer(serializers.ModelSerializer): - class Meta: model = PlatformAutomation fields = [ diff --git a/apps/locale/ja/LC_MESSAGES/django.po b/apps/locale/ja/LC_MESSAGES/django.po index d5e72d0e0..ca196b2f7 100644 --- a/apps/locale/ja/LC_MESSAGES/django.po +++ b/apps/locale/ja/LC_MESSAGES/django.po @@ -656,18 +656,15 @@ msgid "All" msgstr "すべて" #: assets/models/account.py:46 -#, fuzzy msgid "Manual input" msgstr "手動入力" #: assets/models/account.py:47 -#, fuzzy msgid "Dynamic user" msgstr "動的コード" #: assets/models/account.py:55 #: authentication/serializers/connect_token_secret.py:47 -#, fuzzy msgid "Su from" msgstr "から切り替え" diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index c57c03c00..524d6d076 100644 --- a/apps/locale/zh/LC_MESSAGES/django.po +++ b/apps/locale/zh/LC_MESSAGES/django.po @@ -651,18 +651,15 @@ msgid "All" msgstr "全部" #: assets/models/account.py:46 -#, fuzzy msgid "Manual input" msgstr "手动输入" #: assets/models/account.py:47 -#, fuzzy msgid "Dynamic user" -msgstr "动态码" +msgstr "同名账号" #: assets/models/account.py:55 #: authentication/serializers/connect_token_secret.py:47 -#, fuzzy msgid "Su from" msgstr "切换自" @@ -688,12 +685,10 @@ msgid "Can view asset history account secret" msgstr "可以查看资产历史账号密码" #: assets/models/account.py:93 assets/serializers/account/account.py:15 -#, fuzzy msgid "Account template" -msgstr "账号名称" +msgstr "账号模版" #: assets/models/account.py:98 -#, fuzzy msgid "Can view asset account template secret" msgstr "可以查看资产账号密码" @@ -765,19 +760,16 @@ msgid "Use SSL" msgstr "使用 SSL" #: assets/models/asset/database.py:10 -#, fuzzy msgid "CA cert" -msgstr "SP 证书" +msgstr "CA 证书" #: assets/models/asset/database.py:11 -#, fuzzy msgid "Client cert" -msgstr "客户端密钥" +msgstr "客户端证书" #: assets/models/asset/database.py:12 -#, fuzzy msgid "Client key" -msgstr "客户端" +msgstr "客户端密钥" #: assets/models/asset/database.py:13 msgid "Allow invalid cert" @@ -798,23 +790,20 @@ msgid "Script" msgstr "" #: assets/models/asset/web.py:13 -#, fuzzy msgid "Autofill" -msgstr "自动" +msgstr "自动代填" #: assets/models/asset/web.py:14 assets/serializers/platform.py:30 -#, fuzzy msgid "Username selector" -msgstr "用户名属性" +msgstr "用户名选择器" #: assets/models/asset/web.py:15 assets/serializers/platform.py:33 -#, fuzzy msgid "Password selector" -msgstr "密码规则" +msgstr "密码选择器" #: assets/models/asset/web.py:16 assets/serializers/platform.py:36 msgid "Submit selector" -msgstr "" +msgstr "确认按钮选择器" #: assets/models/automations/base.py:17 assets/models/cmd_filter.py:43 #: assets/serializers/asset/common.py:69 perms/models/asset_permission.py:65 @@ -831,9 +820,8 @@ msgid "Assets" msgstr "资产" #: assets/models/automations/base.py:82 assets/models/automations/base.py:89 -#, fuzzy msgid "Automation task" -msgstr "托管密码" +msgstr "自动化任务" #: assets/models/automations/base.py:91 audits/models.py:129 #: audits/serializers.py:41 ops/models/base.py:49 ops/models/job.py:102 @@ -865,7 +853,6 @@ msgstr "结束日期" #: assets/models/automations/base.py:96 #: assets/serializers/automations/base.py:39 -#, fuzzy msgid "Automation snapshot" msgstr "工单快照" @@ -879,21 +866,18 @@ msgstr "触发模式" #: assets/models/automations/base.py:104 #: assets/serializers/automations/change_secret.py:103 -#, fuzzy msgid "Automation task execution" -msgstr "同步实例任务执行" +msgstr "自动化任务执行历史" #: assets/models/automations/change_secret.py:15 assets/models/base.py:67 #: assets/serializers/account/account.py:97 assets/serializers/base.py:13 -#, fuzzy msgid "Secret type" -msgstr "Secret key" +msgstr "密问类型" #: assets/models/automations/change_secret.py:19 #: assets/serializers/automations/change_secret.py:25 -#, fuzzy msgid "Secret strategy" -msgstr "Secret key" +msgstr "密文策略" #: assets/models/automations/change_secret.py:21 #: assets/models/automations/change_secret.py:57 assets/models/base.py:69 @@ -909,7 +893,6 @@ msgid "Password rules" msgstr "密码规则" #: assets/models/automations/change_secret.py:25 -#, fuzzy msgid "SSH key change strategy" msgstr "SSH 密钥策略" @@ -923,59 +906,49 @@ msgid "Recipient" msgstr "收件人" #: assets/models/automations/change_secret.py:34 -#, fuzzy msgid "Change secret automation" -msgstr "安全设置" +msgstr "自动化改密" #: assets/models/automations/change_secret.py:56 -#, fuzzy msgid "Old secret" -msgstr "OTP 秘钥" +msgstr "原密码" #: assets/models/automations/change_secret.py:58 -#, fuzzy msgid "Date started" msgstr "开始日期" #: assets/models/automations/change_secret.py:61 common/const/choices.py:20 -#, fuzzy msgid "Error" -msgstr "企业微信错误" +msgstr "错误" #: assets/models/automations/change_secret.py:64 -#, fuzzy msgid "Change secret record" -msgstr "更改密码" +msgstr "改密记录" #: assets/models/automations/discovery_account.py:8 msgid "Discovery account automation" -msgstr "" +msgstr "账号发现" #: assets/models/automations/gather_accounts.py:15 #: assets/tasks/gather_accounts.py:28 -#, fuzzy msgid "Gather asset accounts" msgstr "收集账号" #: assets/models/automations/gather_facts.py:15 -#, fuzzy msgid "Gather asset facts" -msgstr "收集资产上的用户" +msgstr "收集资产信息" #: assets/models/automations/ping.py:15 -#, fuzzy msgid "Ping asset" -msgstr "登录资产" +msgstr "测试资产" #: assets/models/automations/push_account.py:16 -#, fuzzy msgid "Push asset account" -msgstr "服务账号" +msgstr "账号推送" #: assets/models/automations/verify_account.py:15 -#, fuzzy msgid "Verify asset account" -msgstr "验证密码/密钥" +msgstr "账号验证" #: assets/models/backup.py:37 assets/models/backup.py:95 msgid "Account backup plan" @@ -1057,9 +1030,8 @@ msgid "Command filter rule" msgstr "命令过滤规则" #: assets/models/gateway.py:61 authentication/models/connection_token.py:101 -#, fuzzy msgid "No account" -msgstr "账号" +msgstr "没有账号" #: assets/models/gateway.py:83 #, fuzzy, python-brace-format @@ -1151,9 +1123,8 @@ msgid "Can match node" msgstr "可以匹配节点" #: assets/models/platform.py:20 -#, fuzzy msgid "Required" -msgstr "需要 MFA 认证" +msgstr "必须的" #: assets/models/platform.py:23 settings/serializers/settings.py:61 #: users/templates/users/reset_password.html:29 @@ -1167,55 +1138,47 @@ msgstr "启用" #: assets/models/platform.py:43 msgid "Ansible config" -msgstr "" +msgstr "Ansible 配置" #: assets/models/platform.py:44 -#, fuzzy msgid "Ping enabled" -msgstr "MFA 已启用" +msgstr "启用资产探活" #: assets/models/platform.py:45 msgid "Ping method" -msgstr "" +msgstr "资产探活方式" #: assets/models/platform.py:46 assets/models/platform.py:56 -#, fuzzy msgid "Gather facts enabled" -msgstr "收集资产上的用户" +msgstr "收集资产信息" #: assets/models/platform.py:47 assets/models/platform.py:58 -#, fuzzy msgid "Gather facts method" -msgstr "收集资产上的用户" +msgstr "收集信息方式" #: assets/models/platform.py:48 -#, fuzzy msgid "Push account enabled" -msgstr "MFA 多因子认证没有开启" +msgstr "启用账号推送" #: assets/models/platform.py:49 msgid "Push account method" -msgstr "" +msgstr "账号推送方式" #: assets/models/platform.py:50 -#, fuzzy msgid "Change password enabled" -msgstr "更改密码" +msgstr "开启账号改密" #: assets/models/platform.py:52 -#, fuzzy msgid "Change password method" -msgstr "更改密码" +msgstr "更改密码方式" #: assets/models/platform.py:53 -#, fuzzy msgid "Verify account enabled" -msgstr "服务账号密钥" +msgstr "开启账号验证" #: assets/models/platform.py:55 -#, fuzzy msgid "Verify account method" -msgstr "验证密码/密钥" +msgstr "账号验证方式" #: assets/models/platform.py:75 tickets/models/ticket/general.py:299 msgid "Meta" @@ -1230,28 +1193,24 @@ msgid "Charset" msgstr "编码" #: assets/models/platform.py:82 -#, fuzzy msgid "Domain enabled" -msgstr "网域名称" +msgstr "启用网域" #: assets/models/platform.py:83 -#, fuzzy msgid "Protocols enabled" -msgstr "协议组" +msgstr "启用协议" #: assets/models/platform.py:85 -#, fuzzy msgid "Su enabled" -msgstr "MFA 已启用" +msgstr "启用账号切换" #: assets/models/platform.py:86 -msgid "SU method" -msgstr "" +msgid "Su method" +msgstr "账号切换方式" #: assets/models/platform.py:88 assets/serializers/platform.py:104 -#, fuzzy msgid "Automation" -msgstr "托管密码" +msgstr "自动化" #: assets/models/utils.py:19 #, python-format @@ -1300,16 +1259,15 @@ msgstr "" #: assets/serializers/account/account.py:18 msgid "Push now" -msgstr "" +msgstr "立即推送" #: assets/serializers/account/account.py:20 -#, fuzzy msgid "Has secret" -msgstr "密钥" +msgstr "已托管密码" #: assets/serializers/account/account.py:27 msgid "Account template not found" -msgstr "" +msgstr "账号模版未找到" #: assets/serializers/account/backup.py:29 #: assets/serializers/automations/base.py:34 ops/mixin.py:22 ops/mixin.py:102 @@ -1337,14 +1295,12 @@ msgid "Address" msgstr "地址" #: assets/serializers/asset/common.py:156 -#, fuzzy msgid "Platform not exist" -msgstr "应用不存在" +msgstr "平台不存在" #: assets/serializers/asset/common.py:172 -#, fuzzy msgid "Protocol is required: {}" -msgstr "协议重复: {}" +msgstr "协议是必填的: {}" #: assets/serializers/asset/host.py:12 msgid "Vendor" @@ -1431,7 +1387,6 @@ msgid "Success" msgstr "成功" #: assets/serializers/automations/gather_accounts.py:23 -#, fuzzy msgid "Executed amount" msgstr "执行次数" @@ -1444,7 +1399,6 @@ msgid "Constraints" msgstr "" #: assets/serializers/cagegory.py:15 -#, fuzzy msgid "Types" msgstr "类型" @@ -1477,23 +1431,17 @@ msgid "The same level node name cannot be the same" msgstr "同级别节点名字不能重复" #: assets/serializers/platform.py:24 -#, fuzzy msgid "SFTP enabled" -msgstr "MFA 已启用" +msgstr "SFTP 已启用" #: assets/serializers/platform.py:25 -#, fuzzy msgid "SFTP home" msgstr "SFTP根路径" -#: assets/serializers/platform.py:28 -#, fuzzy -msgid "Auto fill" -msgstr "自动" #: assets/serializers/platform.py:79 msgid "Primary" -msgstr "" +msgstr "主要的" #: assets/serializers/utils.py:13 msgid "Password can not contains `{{` " @@ -1512,36 +1460,32 @@ msgid "private key invalid or passphrase error" msgstr "密钥不合法或密钥密码错误" #: assets/tasks/automation.py:11 -#, fuzzy msgid "Execute automation" -msgstr "执行批量命令" +msgstr "执行自动化任务" #: assets/tasks/backup.py:13 -#, fuzzy msgid "Execute account backup plan" -msgstr "账号备份计划" +msgstr "执行账号备份计划" #: assets/tasks/gather_accounts.py:31 -#, fuzzy msgid "Gather assets accounts" -msgstr "收集资产上的用户" +msgstr "收集资产上的账号" #: assets/tasks/gather_facts.py:26 msgid "Update some assets hardware info. " msgstr "更新资产硬件信息. " #: assets/tasks/gather_facts.py:44 -#, fuzzy msgid "Manually update the hardware information of assets" -msgstr "更新节点资产硬件信息: " +msgstr "手动更新资产信息" #: assets/tasks/gather_facts.py:49 msgid "Update assets hardware info: " -msgstr "更新资产硬件信息: " +msgstr "更新资产硬件信息" #: assets/tasks/gather_facts.py:53 msgid "Manually update the hardware information of assets under a node" -msgstr "" +msgstr "手动更新节点下资产信息" #: assets/tasks/gather_facts.py:59 msgid "Update node asset hardware information: " @@ -1549,7 +1493,7 @@ msgstr "更新节点资产硬件信息: " #: assets/tasks/nodes_amount.py:16 msgid "Check the amount of assets under the node" -msgstr "" +msgstr "检查节点下资产数量" #: assets/tasks/nodes_amount.py:28 msgid "" @@ -1558,31 +1502,27 @@ msgstr "自检程序已经在运行,不能重复启动" #: assets/tasks/nodes_amount.py:34 msgid "Periodic check the amount of assets under the node" -msgstr "" +msgstr "周期性检查节点下资产数量" #: assets/tasks/ping.py:21 assets/tasks/ping.py:39 -#, fuzzy msgid "Test assets connectivity " -msgstr "测试资产可连接性. " +msgstr "测试资产可连接性" #: assets/tasks/ping.py:33 -#, fuzzy msgid "Manually test the connectivity of a asset" -msgstr "可以测试资产连接性" +msgstr "手动测试资产连接性" #: assets/tasks/ping.py:43 msgid "Manually test the connectivity of assets under a node" -msgstr "" +msgstr "手动测试节点下资产连接性" #: assets/tasks/ping.py:49 -#, fuzzy msgid "Test if the assets under the node are connectable " -msgstr "测试节点下资产是否可连接: " +msgstr "测试节点下资产是否可连接" #: assets/tasks/push_account.py:17 assets/tasks/push_account.py:34 -#, fuzzy msgid "Push accounts to assets" -msgstr "推送系统用户到入资产: " +msgstr "推送账号到资产" #: assets/tasks/utils.py:17 msgid "Asset has been disabled, skipped: {}" @@ -1605,9 +1545,8 @@ msgid "Verify asset account availability" msgstr "" #: assets/tasks/verify_account.py:37 -#, fuzzy msgid "Verify accounts connectivity" -msgstr "测试账号可连接性: " +msgstr "测试账号可连接性" #: audits/apps.py:9 msgid "Audits" @@ -1975,11 +1914,10 @@ msgid "" msgstr "账号已被锁定(请联系管理员解锁或{}分钟后重试)" #: authentication/errors/const.py:51 -#, fuzzy msgid "" "The address has been locked (please contact admin to unlock it or try again " "after {} minutes)" -msgstr "IP 已被锁定(请联系管理员解锁或{}分钟后重试)" +msgstr "IP 已被锁定(请联系管理员解锁或 {} 分钟后重试)" #: authentication/errors/const.py:59 #, python-brace-format @@ -2174,21 +2112,18 @@ msgid "Account name" msgstr "账号名称" #: authentication/models/connection_token.py:32 -#, fuzzy msgid "Input username" msgstr "自定义用户名" #: authentication/models/connection_token.py:33 -#, fuzzy msgid "Input secret" -msgstr "客户端密钥" +msgstr "自定义密码" #: authentication/models/connection_token.py:35 #: authentication/serializers/connect_token_secret.py:110 #: perms/models/perm_token.py:17 -#, fuzzy msgid "Connect method" -msgstr "连接超时时间" +msgstr "连接方式" #: authentication/models/connection_token.py:36 #: rbac/serializers/rolebinding.py:21 @@ -2220,12 +2155,11 @@ msgstr "连接令牌过期: {}" #: authentication/models/connection_token.py:94 msgid "No user or invalid user" -msgstr "" +msgstr "没有用户或用户失效" #: authentication/models/connection_token.py:98 -#, fuzzy msgid "No asset or inactive asset" -msgstr "资产未激活" +msgstr "没有资产或资产未激活" #: authentication/models/connection_token.py:173 msgid "Super connection token" @@ -2256,9 +2190,8 @@ msgid "binding reminder" msgstr "绑定提醒" #: authentication/serializers/connect_token_secret.py:109 -#, fuzzy msgid "Expired now" -msgstr "过期时间" +msgstr "立刻过期" #: authentication/serializers/connection_token.py:14 msgid "Expired time" @@ -2674,10 +2607,9 @@ msgstr "待定的" #: common/const/choices.py:17 msgid "Running" -msgstr "" +msgstr "运行中" #: common/const/choices.py:21 -#, fuzzy msgid "Canceled" msgstr "取消" @@ -2745,9 +2677,8 @@ msgid "Invalid data type, should be list" msgstr "" #: common/drf/fields.py:156 -#, fuzzy msgid "Invalid choice: {}" -msgstr "无效IP" +msgstr "无效选项: {}" #: common/drf/parsers/base.py:17 msgid "The file content overflowed (The maximum length `{}` bytes)" @@ -2762,9 +2693,8 @@ msgid "Children" msgstr "" #: common/drf/serializers/common.py:94 -#, fuzzy msgid "File" -msgstr "文件名" +msgstr "文件" #: common/exceptions.py:15 #, python-format @@ -2885,22 +2815,20 @@ msgid "Please wait {} seconds before sending" msgstr "请在 {} 秒后发送" #: common/tasks.py:13 -#, fuzzy msgid "Send email" -msgstr "发件人" +msgstr "发件邮件" #: common/tasks.py:40 msgid "Send email attachment" -msgstr "" +msgstr "发送邮件附件" #: common/utils/ip/geoip/utils.py:26 msgid "Invalid ip" msgstr "无效IP" #: common/utils/ip/utils.py:78 -#, fuzzy msgid "Invalid address" -msgstr "签名无效" +msgstr "无效地址" #: common/validators.py:14 msgid "Special char not allowed" @@ -2986,18 +2914,16 @@ msgid "Publish the station message" msgstr "" #: ops/ansible/inventory.py:75 -#, fuzzy msgid "No account available" -msgstr "账号无效" +msgstr "无可用账号" #: ops/ansible/inventory.py:178 -#, fuzzy msgid "Ansible disabled" -msgstr "用户已禁用" +msgstr "Ansible 已禁用" #: ops/ansible/inventory.py:194 msgid "Skip hosts below:" -msgstr "" +msgstr "跳过以下主机: " #: ops/api/celery.py:63 ops/api/celery.py:78 msgid "Waiting task start" @@ -3009,21 +2935,19 @@ msgstr "作业中心" #: ops/const.py:6 msgid "Push" -msgstr "" +msgstr "推送" #: ops/const.py:7 -#, fuzzy msgid "Verify" -msgstr "已校验" +msgstr "校验" #: ops/const.py:8 msgid "Collect" -msgstr "" +msgstr "收集" #: ops/const.py:9 -#, fuzzy msgid "Change password" -msgstr "更改密码" +msgstr "改密" #: ops/const.py:19 xpack/plugins/change_auth_plan/models/base.py:27 msgid "Custom password" @@ -3031,7 +2955,7 @@ msgstr "自定义密码" #: ops/exception.py:6 msgid "no valid program entry found." -msgstr "" +msgstr "没有可用程序入口" #: ops/mixin.py:25 ops/mixin.py:88 settings/serializers/auth/ldap.py:73 msgid "Cycle perform" @@ -3059,7 +2983,6 @@ msgid "Require periodic or regularly perform setting" msgstr "需要周期或定期设置" #: ops/models/adhoc.py:18 ops/models/job.py:31 -#, fuzzy msgid "Powershell" msgstr "PowerShell" @@ -3069,7 +2992,7 @@ msgstr "模式" #: ops/models/adhoc.py:24 ops/models/job.py:38 msgid "Module" -msgstr "" +msgstr "模块" #: ops/models/adhoc.py:25 ops/models/celery.py:54 ops/models/job.py:36 #: terminal/models/component/task.py:17 @@ -3083,19 +3006,16 @@ msgid "Creator" msgstr "创建者" #: ops/models/base.py:19 -#, fuzzy msgid "Account policy" -msgstr "账号密钥" +msgstr "账号策略" #: ops/models/base.py:20 -#, fuzzy msgid "Last execution" -msgstr "命令执行" +msgstr "最后执行" #: ops/models/base.py:22 -#, fuzzy msgid "Date last run" -msgstr "最后同步日期" +msgstr "最后运行日期" #: ops/models/base.py:51 ops/models/job.py:105 #: xpack/plugins/cloud/models.py:172 @@ -3104,7 +3024,7 @@ msgstr "结果" #: ops/models/base.py:52 ops/models/job.py:106 msgid "Summary" -msgstr "" +msgstr "汇总" #: ops/models/celery.py:55 terminal/models/component/task.py:18 msgid "Kwargs" @@ -3122,29 +3042,28 @@ msgid "Finished" msgstr "结束" #: ops/models/celery.py:58 -#, fuzzy msgid "Date published" -msgstr "结束日期" +msgstr "发布日期" #: ops/models/job.py:21 msgid "Adhoc" -msgstr "" +msgstr "命令" #: ops/models/job.py:22 ops/models/job.py:41 msgid "Playbook" -msgstr "" +msgstr "Playbook" #: ops/models/job.py:25 msgid "Privileged Only" -msgstr "" +msgstr "仅限特权账号" #: ops/models/job.py:26 msgid "Privileged First" -msgstr "" +msgstr "特权账号优先" #: ops/models/job.py:27 msgid "Skip" -msgstr "" +msgstr "跳过" #: ops/models/job.py:39 msgid "Chdir" @@ -3203,14 +3122,12 @@ msgid "CPU load more than {max_threshold}: => {value}" msgstr "CPU 使用率超过 {max_threshold}: => {value}" #: ops/serializers/job.py:10 -#, fuzzy msgid "Run after save" -msgstr "运行的系统用户" +msgstr "保存后执行" #: ops/serializers/job.py:11 -#, fuzzy msgid "Job type" -msgstr "文档类型" +msgstr "任务类型" #: ops/signal_handlers.py:65 terminal/models/applet/host.py:108 #: terminal/models/component/task.py:26 @@ -3219,36 +3136,32 @@ msgid "Task" msgstr "任务" #: ops/tasks.py:28 -#, fuzzy msgid "Run ansible task" -msgstr "运行的资产" +msgstr "运行 Ansible 任务" #: ops/tasks.py:35 -#, fuzzy msgid "Run ansible task execution" -msgstr "同步实例任务执行" +msgstr "开始执行 Ansible 任务" #: ops/tasks.py:48 msgid "Periodic clear celery tasks" -msgstr "" +msgstr "周期清理不可用任务" #: ops/tasks.py:50 msgid "Clean celery log period" -msgstr "定期清除Celery日志" +msgstr "定期清除任务日志" #: ops/tasks.py:67 -#, fuzzy msgid "Clear celery periodic tasks" -msgstr "定期清除Celery日志" +msgstr "清理周期任务" #: ops/tasks.py:90 msgid "Create or update periodic tasks" -msgstr "" +msgstr "创建或更新周期任务" #: ops/tasks.py:98 -#, fuzzy msgid "Periodic check service performance" -msgstr "定时执行" +msgstr "周期检测服务性能" #: ops/templates/ops/celery_task_log.html:4 msgid "Task log" @@ -3288,9 +3201,8 @@ msgid "Org name" msgstr "组织名称" #: orgs/models.py:72 -#, fuzzy msgid "Builtin" -msgstr "内置" +msgstr "内置的" #: orgs/models.py:80 msgid "GLOBAL" @@ -3298,11 +3210,11 @@ msgstr "全局组织" #: orgs/models.py:82 msgid "DEFAULT" -msgstr "" +msgstr "默认组织" #: orgs/models.py:84 msgid "SYSTEM" -msgstr "" +msgstr "系统组织" #: orgs/models.py:90 msgid "Can view root org" @@ -3313,9 +3225,8 @@ msgid "Can view all joined org" msgstr "可以查看所有加入的组织" #: orgs/tasks.py:9 -#, fuzzy msgid "Refresh organization cache" -msgstr "全局组织名" +msgstr "刷新组织缓存" #: perms/apps.py:9 msgid "App permissions" @@ -3326,22 +3237,20 @@ msgid "Connect" msgstr "连接" #: perms/const.py:15 -#, fuzzy msgid "Copy" -msgstr "复制链接" +msgstr "复制" #: perms/const.py:16 msgid "Paste" -msgstr "" +msgstr "粘贴" #: perms/const.py:26 msgid "Transfer" -msgstr "" +msgstr "文件传输" #: perms/const.py:27 -#, fuzzy msgid "Clipboard" -msgstr "剪贴板复制" +msgstr "剪贴板" #: perms/models/asset_permission.py:66 perms/models/perm_token.py:18 #: perms/serializers/permission.py:29 perms/serializers/permission.py:59 @@ -3383,13 +3292,12 @@ msgid "Can view usergroup assets" msgstr "可以查看用户组授权的资产" #: perms/models/perm_node.py:119 -#, fuzzy msgid "Permed account" -msgstr "收集账号" +msgstr "授权账号" #: perms/notifications.py:12 perms/notifications.py:44 msgid "today" -msgstr "今" +msgstr "今天" #: perms/notifications.py:15 msgid "You permed assets is about to expire" @@ -5075,7 +4983,6 @@ msgid "Session ID" msgstr "会话ID" #: terminal/backends/command/serializers.py:37 -#, fuzzy msgid "Account " msgstr "账号" @@ -5110,7 +5017,6 @@ msgstr "离线" #: terminal/const.py:81 terminal/const.py:82 terminal/const.py:83 #: terminal/const.py:84 terminal/const.py:85 -#, fuzzy msgid "DB Client" msgstr "客户端" @@ -5123,50 +5029,44 @@ msgid "Storage is invalid" msgstr "存储无效" #: terminal/models/applet/applet.py:23 -#, fuzzy msgid "Author" -msgstr "资产账号" +msgstr "作者" #: terminal/models/applet/applet.py:27 msgid "Tags" -msgstr "" +msgstr "标签" #: terminal/models/applet/applet.py:31 terminal/serializers/storage.py:157 msgid "Hosts" msgstr "主机" #: terminal/models/applet/applet.py:58 terminal/models/applet/host.py:27 -#, fuzzy msgid "Applet" -msgstr "申请资产" +msgstr "远程应用" #: terminal/models/applet/host.py:18 terminal/serializers/applet_host.py:38 -#, fuzzy msgid "Deploy options" -msgstr "其他方式登录" +msgstr "部署参数" #: terminal/models/applet/host.py:19 msgid "Inited" -msgstr "" +msgstr "已初始化" #: terminal/models/applet/host.py:20 -#, fuzzy msgid "Date inited" -msgstr "结束日期" +msgstr "初始化日期" #: terminal/models/applet/host.py:21 -#, fuzzy msgid "Date synced" msgstr "同步日期" #: terminal/models/applet/host.py:102 -#, fuzzy msgid "Hosting" -msgstr "主机" +msgstr "宿主机" #: terminal/models/applet/host.py:103 msgid "Initial" -msgstr "" +msgstr "初始化" #: terminal/models/component/endpoint.py:15 msgid "HTTPS Port" @@ -5363,45 +5263,40 @@ msgid "Batch danger command alert" msgstr "批量危险命令告警" #: terminal/serializers/applet.py:16 -#, fuzzy msgid "Published" -msgstr "SSH公钥" +msgstr "已发布" #: terminal/serializers/applet.py:17 -#, fuzzy msgid "Unpublished" -msgstr "结束" +msgstr "未发布" #: terminal/serializers/applet.py:18 -#, fuzzy msgid "Not match" -msgstr "没有匹配到用户" +msgstr "没有匹配的" #: terminal/serializers/applet.py:32 msgid "Icon" -msgstr "" +msgstr "图标" #: terminal/serializers/applet_host.py:21 -#, fuzzy msgid "Per Session" -msgstr "会话" +msgstr "每会话" #: terminal/serializers/applet_host.py:22 msgid "Per Device" -msgstr "" +msgstr "每设备" #: terminal/serializers/applet_host.py:28 -#, fuzzy msgid "RDS Licensing" -msgstr "许可证" +msgstr "RDS 许可证" #: terminal/serializers/applet_host.py:29 msgid "RDS License Server" -msgstr "" +msgstr "RDS 许可服务器" #: terminal/serializers/applet_host.py:30 msgid "RDS Licensing Mode" -msgstr "" +msgstr "RDS 授权模式" #: terminal/serializers/applet_host.py:32 msgid "RDS fSingleSessionPerUser" diff --git a/apps/orgs/mixins/models.py b/apps/orgs/mixins/models.py index 0795edc2e..d9eef1e2f 100644 --- a/apps/orgs/mixins/models.py +++ b/apps/orgs/mixins/models.py @@ -1,16 +1,16 @@ # -*- coding: utf-8 -*- # +from django.core.exceptions import ValidationError from django.db import models from django.utils.translation import ugettext_lazy as _ -from django.core.exceptions import ValidationError -from common.utils import get_logger from common.db.models import JMSBaseModel +from common.utils import get_logger, lazyproperty +from ..models import Organization from ..utils import ( set_current_org, get_current_org, current_org, filter_org_queryset ) -from ..models import Organization logger = get_logger(__file__) @@ -75,7 +75,7 @@ class OrgModelMixin(models.Model): self.org_id = org.id return super().save(*args, **kwargs) - @property + @lazyproperty def org(self): return Organization.get_instance(self.org_id) diff --git a/apps/orgs/models.py b/apps/orgs/models.py index 73dc3c6ad..89f50f4bb 100644 --- a/apps/orgs/models.py +++ b/apps/orgs/models.py @@ -3,8 +3,8 @@ import uuid from django.db import models from django.utils.translation import ugettext_lazy as _ -from common.utils import lazyproperty, settings from common.tree import TreeNode +from common.utils import lazyproperty, settings class OrgRoleMixin: @@ -33,7 +33,6 @@ class OrgRoleMixin: def get_origin_role_members(self, role_name): from rbac.models import OrgRoleBinding - from users.models import User from rbac.builtin import BuiltinRole from .utils import tmp_to_org @@ -132,6 +131,7 @@ class Organization(OrgRoleMixin, models.Model): @classmethod def expire_orgs_mapping(cls): + print("Expire orgs mapping: ") cls.orgs_mapping = None def org_id(self): diff --git a/apps/orgs/signal_handlers/common.py b/apps/orgs/signal_handlers/common.py index 4935eeec9..802e9c299 100644 --- a/apps/orgs/signal_handlers/common.py +++ b/apps/orgs/signal_handlers/common.py @@ -56,6 +56,7 @@ def subscribe_orgs_mapping_expire(sender, **kwargs): def on_org_create_or_update(sender, instance, created=False, **kwargs): # 必须放到最开始, 因为下面调用Node.save方法时会获取当前组织的org_id(即instance.org_id), 如果不过期会找不到 expire_orgs_mapping_for_memory(instance.id) + old_org = get_current_org() set_current_org(instance) node_root = Node.org_root()