diff --git a/apps/assets/migrations/0121_auto_20230725_1458.py b/apps/assets/migrations/0121_auto_20230725_1458.py index d32eb86a1..65a115cce 100644 --- a/apps/assets/migrations/0121_auto_20230725_1458.py +++ b/apps/assets/migrations/0121_auto_20230725_1458.py @@ -6,7 +6,10 @@ from django.db import migrations def migrate_platforms_sftp_protocol(apps, schema_editor): platform_protocol_cls = apps.get_model('assets', 'PlatformProtocol') platform_cls = apps.get_model('assets', 'Platform') - ssh_protocols = platform_protocol_cls.objects.filter(name='ssh', setting__sftp_enabled=True) + ssh_protocols = platform_protocol_cls.objects \ + .filter(name='ssh', setting__sftp_enabled=True) \ + .exclude(name__in=('Gateway', 'RemoteAppHost')) \ + .filter(type='linux') platforms_has_sftp = platform_cls.objects.filter(protocols__name='sftp') new_protocols = [] diff --git a/apps/jumpserver/settings/custom.py b/apps/jumpserver/settings/custom.py index b9be9c75b..16d503f1c 100644 --- a/apps/jumpserver/settings/custom.py +++ b/apps/jumpserver/settings/custom.py @@ -86,7 +86,6 @@ TERMINAL_TELNET_REGEX = CONFIG.TERMINAL_TELNET_REGEX # 默认图形化分辨率 TERMINAL_GRAPHICAL_RESOLUTION = CONFIG.TERMINAL_GRAPHICAL_RESOLUTION - # Asset user auth external backend, default AuthBook backend BACKEND_ASSET_USER_AUTH_VAULT = False diff --git a/apps/locale/ja/LC_MESSAGES/django.po b/apps/locale/ja/LC_MESSAGES/django.po index 424fbf22b..a87020f10 100644 --- a/apps/locale/ja/LC_MESSAGES/django.po +++ b/apps/locale/ja/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-25 15:37+0800\n" +"POT-Creation-Date: 2023-07-28 10:38+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -288,7 +288,7 @@ msgstr "アカウントバックアップ計画" #: assets/models/automations/base.py:115 audits/models.py:60 #: ops/models/base.py:55 ops/models/celery.py:63 ops/models/job.py:194 #: ops/templates/ops/celery_task_log.html:75 -#: perms/models/asset_permission.py:72 terminal/models/applet/host.py:137 +#: perms/models/asset_permission.py:72 terminal/models/applet/host.py:139 #: terminal/models/session/session.py:44 #: tickets/models/ticket/apply_application.py:30 #: tickets/models/ticket/apply_asset.py:19 @@ -411,7 +411,7 @@ msgstr "開始日" #: accounts/models/automations/change_secret.py:91 #: assets/models/automations/base.py:116 ops/models/base.py:56 #: ops/models/celery.py:64 ops/models/job.py:195 -#: terminal/models/applet/host.py:138 +#: terminal/models/applet/host.py:140 msgid "Date finished" msgstr "終了日" @@ -696,7 +696,7 @@ msgid "Key password" msgstr "キーパスワード" #: accounts/serializers/account/base.py:80 -#: assets/serializers/asset/common.py:309 +#: assets/serializers/asset/common.py:311 msgid "Spec info" msgstr "特別情報" @@ -839,7 +839,7 @@ msgid "Users" msgstr "ユーザー" #: acls/models/base.py:98 assets/models/automations/base.py:17 -#: assets/models/cmd_filter.py:38 assets/serializers/asset/common.py:308 +#: assets/models/cmd_filter.py:38 assets/serializers/asset/common.py:310 #: rbac/tree.py:35 msgid "Accounts" msgstr "アカウント" @@ -1080,7 +1080,7 @@ msgstr "無効" msgid "Basic" msgstr "基本" -#: assets/const/base.py:35 assets/const/protocol.py:193 +#: assets/const/base.py:35 assets/const/protocol.py:201 #: assets/models/asset/web.py:13 msgid "Script" msgstr "脚本" @@ -1152,10 +1152,6 @@ msgstr "" msgid "Other" msgstr "その他" -#: assets/const/protocol.py:43 -msgid "SFTP enabled" -msgstr "SFTP が有効" - #: assets/const/protocol.py:48 msgid "SFTP home" msgstr "SFTP ルート パス" @@ -1189,28 +1185,36 @@ msgstr "AD ドメイン" msgid "Use SSL" msgstr "SSLの使用" -#: assets/const/protocol.py:149 +#: assets/const/protocol.py:127 +msgid "SYSDBA" +msgstr "" + +#: assets/const/protocol.py:128 +msgid "Connect as SYSDBA" +msgstr "" + +#: assets/const/protocol.py:157 msgid "Auth username" msgstr "ユーザー名で認証する" -#: assets/const/protocol.py:170 assets/models/asset/web.py:9 +#: assets/const/protocol.py:178 assets/models/asset/web.py:9 #: assets/serializers/asset/info/spec.py:16 msgid "Autofill" msgstr "自動充填" -#: assets/const/protocol.py:178 assets/models/asset/web.py:10 +#: assets/const/protocol.py:186 assets/models/asset/web.py:10 msgid "Username selector" msgstr "ユーザー名ピッカー" -#: assets/const/protocol.py:183 assets/models/asset/web.py:11 +#: assets/const/protocol.py:191 assets/models/asset/web.py:11 msgid "Password selector" msgstr "パスワードセレクター" -#: assets/const/protocol.py:188 assets/models/asset/web.py:12 +#: assets/const/protocol.py:196 assets/models/asset/web.py:12 msgid "Submit selector" msgstr "ボタンセレクターを確認する" -#: assets/const/protocol.py:211 +#: assets/const/protocol.py:219 msgid "API mode" msgstr "APIモード" @@ -1239,7 +1243,7 @@ msgstr "SSHパブリックキー" #: common/db/models.py:36 ops/models/adhoc.py:26 ops/models/job.py:113 #: ops/models/playbook.py:26 rbac/models/role.py:37 settings/models.py:37 #: terminal/models/applet/applet.py:44 terminal/models/applet/applet.py:248 -#: terminal/models/applet/host.py:139 terminal/models/component/endpoint.py:24 +#: terminal/models/applet/host.py:141 terminal/models/component/endpoint.py:24 #: terminal/models/component/endpoint.py:102 #: terminal/models/session/session.py:46 tickets/models/comment.py:32 #: tickets/models/ticket/general.py:297 users/models/user.py:792 @@ -1368,7 +1372,7 @@ msgstr "ドメイン" msgid "Labels" msgstr "ラベル" -#: assets/models/asset/common.py:158 assets/serializers/asset/common.py:310 +#: assets/models/asset/common.py:158 assets/serializers/asset/common.py:312 #: assets/serializers/asset/host.py:11 msgid "Gathered info" msgstr "資産ハードウェア情報の収集" @@ -1432,9 +1436,9 @@ msgstr "アセットの自動化タスク" #: assets/models/automations/base.py:113 audits/models.py:199 #: audits/serializers.py:50 ops/models/base.py:49 ops/models/job.py:186 -#: terminal/models/applet/applet.py:247 terminal/models/applet/host.py:136 +#: terminal/models/applet/applet.py:247 terminal/models/applet/host.py:138 #: terminal/models/component/status.py:30 terminal/serializers/applet.py:18 -#: terminal/serializers/applet_host.py:107 tickets/models/ticket/general.py:283 +#: terminal/serializers/applet_host.py:108 tickets/models/ticket/general.py:283 #: tickets/serializers/super_ticket.py:13 #: tickets/serializers/ticket/ticket.py:20 xpack/plugins/cloud/models.py:164 #: xpack/plugins/cloud/models.py:216 @@ -1702,19 +1706,19 @@ msgid "Node path" msgstr "ノードパスです" #: assets/serializers/asset/common.py:145 -#: assets/serializers/asset/common.py:311 +#: assets/serializers/asset/common.py:313 msgid "Auto info" msgstr "自動情報" -#: assets/serializers/asset/common.py:234 +#: assets/serializers/asset/common.py:236 msgid "Platform not exist" msgstr "プラットフォームが存在しません" -#: assets/serializers/asset/common.py:270 +#: assets/serializers/asset/common.py:272 msgid "port out of range (0-65535)" msgstr "ポート番号が範囲外です (0-65535)" -#: assets/serializers/asset/common.py:277 +#: assets/serializers/asset/common.py:279 msgid "Protocol is required: {}" msgstr "プロトコルが必要です: {}" @@ -2022,7 +2026,7 @@ msgid "Change password" msgstr "パスワードを変更する" #: audits/const.py:35 settings/serializers/terminal.py:6 -#: terminal/models/applet/host.py:25 terminal/models/component/terminal.py:163 +#: terminal/models/applet/host.py:26 terminal/models/component/terminal.py:163 #: terminal/serializers/session.py:46 terminal/serializers/session.py:55 msgid "Terminal" msgstr "ターミナル" @@ -2039,7 +2043,7 @@ msgstr "セッションログ" msgid "Login log" msgstr "ログインログ" -#: audits/const.py:43 terminal/models/applet/host.py:140 +#: audits/const.py:43 terminal/models/applet/host.py:142 #: terminal/models/component/task.py:24 msgid "Task" msgstr "タスク" @@ -2250,19 +2254,19 @@ msgstr "" msgid "Anonymous account is not supported for this asset" msgstr "匿名アカウントはこのプロパティではサポートされていません" -#: authentication/api/connection_token.py:323 +#: authentication/api/connection_token.py:320 msgid "Account not found" msgstr "アカウントが見つかりません" -#: authentication/api/connection_token.py:326 +#: authentication/api/connection_token.py:323 msgid "Permission expired" msgstr "承認の有効期限が切れています" -#: authentication/api/connection_token.py:340 +#: authentication/api/connection_token.py:337 msgid "ACL action is reject: {}({})" msgstr "ACL アクションは拒否です: {}({})" -#: authentication/api/connection_token.py:344 +#: authentication/api/connection_token.py:341 msgid "ACL action is review" msgstr "ACL アクションはレビューです" @@ -2718,11 +2722,11 @@ msgstr "ユーザーなしまたは期限切れのユーザー" msgid "No asset or inactive asset" msgstr "アセットがないか、有効化されていないアセット" -#: authentication/models/connection_token.py:269 +#: authentication/models/connection_token.py:280 msgid "Can view super connection token secret" msgstr "スーパー接続トークンのシークレットを表示できます" -#: authentication/models/connection_token.py:271 +#: authentication/models/connection_token.py:282 msgid "Super connection token" msgstr "スーパー接続トークン" @@ -4243,7 +4247,7 @@ msgid "My assets" msgstr "私の資産" #: rbac/tree.py:56 terminal/models/applet/applet.py:51 -#: terminal/models/applet/applet.py:244 terminal/models/applet/host.py:28 +#: terminal/models/applet/applet.py:244 terminal/models/applet/host.py:29 #: terminal/serializers/applet.py:15 msgid "Applet" msgstr "リモートアプリケーション" @@ -5742,7 +5746,7 @@ msgstr "出力" msgid "Risk level" msgstr "リスクレベル" -#: terminal/connect_methods.py:34 +#: terminal/connect_methods.py:35 msgid "DB Client" msgstr "データベース クライアント" @@ -5847,28 +5851,36 @@ msgstr "カスタムプラットフォームのみをサポート" msgid "Missing type in platform.yml" msgstr "platform.ymlにタイプがありません" -#: terminal/models/applet/applet.py:246 terminal/models/applet/host.py:34 -#: terminal/models/applet/host.py:134 +#: terminal/models/applet/applet.py:246 terminal/models/applet/host.py:35 +#: terminal/models/applet/host.py:136 msgid "Hosting" msgstr "ホスト マシン" -#: terminal/models/applet/host.py:19 terminal/serializers/applet_host.py:57 +#: terminal/models/applet/host.py:18 terminal/serializers/applet_host.py:57 msgid "Deploy options" msgstr "展開パラメーター" +#: terminal/models/applet/host.py:19 +msgid "Auto create accounts" +msgstr "アカウントの自動作成" + #: terminal/models/applet/host.py:20 +msgid "Accounts create amount" +msgstr "作成するアカウント数" + +#: terminal/models/applet/host.py:21 msgid "Inited" msgstr "初期化された" -#: terminal/models/applet/host.py:21 +#: terminal/models/applet/host.py:22 msgid "Date inited" msgstr "" -#: terminal/models/applet/host.py:22 +#: terminal/models/applet/host.py:23 msgid "Date synced" msgstr "同期日" -#: terminal/models/applet/host.py:135 +#: terminal/models/applet/host.py:137 msgid "Initial" msgstr "初期化" @@ -7892,6 +7904,9 @@ msgstr "究極のエディション" msgid "Community edition" msgstr "コミュニティ版" +#~ msgid "SFTP enabled" +#~ msgstr "SFTP が有効" + #~ msgid "Item" #~ msgstr "アイテム" diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index 10fd864cc..388a31294 100644 --- a/apps/locale/zh/LC_MESSAGES/django.po +++ b/apps/locale/zh/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: JumpServer 0.3.3\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-07-25 15:37+0800\n" +"POT-Creation-Date: 2023-07-28 10:38+0800\n" "PO-Revision-Date: 2021-05-20 10:54+0800\n" "Last-Translator: ibuler \n" "Language-Team: JumpServer team\n" @@ -287,7 +287,7 @@ msgstr "账号备份计划" #: assets/models/automations/base.py:115 audits/models.py:60 #: ops/models/base.py:55 ops/models/celery.py:63 ops/models/job.py:194 #: ops/templates/ops/celery_task_log.html:75 -#: perms/models/asset_permission.py:72 terminal/models/applet/host.py:137 +#: perms/models/asset_permission.py:72 terminal/models/applet/host.py:139 #: terminal/models/session/session.py:44 #: tickets/models/ticket/apply_application.py:30 #: tickets/models/ticket/apply_asset.py:19 @@ -410,7 +410,7 @@ msgstr "开始日期" #: accounts/models/automations/change_secret.py:91 #: assets/models/automations/base.py:116 ops/models/base.py:56 #: ops/models/celery.py:64 ops/models/job.py:195 -#: terminal/models/applet/host.py:138 +#: terminal/models/applet/host.py:140 msgid "Date finished" msgstr "结束日期" @@ -692,7 +692,7 @@ msgid "Key password" msgstr "密钥密码" #: accounts/serializers/account/base.py:80 -#: assets/serializers/asset/common.py:309 +#: assets/serializers/asset/common.py:311 msgid "Spec info" msgstr "特殊信息" @@ -835,7 +835,7 @@ msgid "Users" msgstr "用户管理" #: acls/models/base.py:98 assets/models/automations/base.py:17 -#: assets/models/cmd_filter.py:38 assets/serializers/asset/common.py:308 +#: assets/models/cmd_filter.py:38 assets/serializers/asset/common.py:310 #: rbac/tree.py:35 msgid "Accounts" msgstr "账号管理" @@ -1073,7 +1073,7 @@ msgstr "禁用" msgid "Basic" msgstr "基本" -#: assets/const/base.py:35 assets/const/protocol.py:193 +#: assets/const/base.py:35 assets/const/protocol.py:201 #: assets/models/asset/web.py:13 msgid "Script" msgstr "脚本" @@ -1145,10 +1145,6 @@ msgstr "ChatGPT" msgid "Other" msgstr "其它" -#: assets/const/protocol.py:43 -msgid "SFTP enabled" -msgstr "SFTP 已启用" - #: assets/const/protocol.py:48 msgid "SFTP home" msgstr "SFTP 根路径" @@ -1182,28 +1178,36 @@ msgstr "AD 网域" msgid "Use SSL" msgstr "使用 SSL" -#: assets/const/protocol.py:149 +#: assets/const/protocol.py:127 +msgid "SYSDBA" +msgstr "" + +#: assets/const/protocol.py:128 +msgid "Connect as SYSDBA" +msgstr "" + +#: assets/const/protocol.py:157 msgid "Auth username" msgstr "使用用户名认证" -#: assets/const/protocol.py:170 assets/models/asset/web.py:9 +#: assets/const/protocol.py:178 assets/models/asset/web.py:9 #: assets/serializers/asset/info/spec.py:16 msgid "Autofill" msgstr "自动代填" -#: assets/const/protocol.py:178 assets/models/asset/web.py:10 +#: assets/const/protocol.py:186 assets/models/asset/web.py:10 msgid "Username selector" msgstr "用户名选择器" -#: assets/const/protocol.py:183 assets/models/asset/web.py:11 +#: assets/const/protocol.py:191 assets/models/asset/web.py:11 msgid "Password selector" msgstr "密码选择器" -#: assets/const/protocol.py:188 assets/models/asset/web.py:12 +#: assets/const/protocol.py:196 assets/models/asset/web.py:12 msgid "Submit selector" msgstr "确认按钮选择器" -#: assets/const/protocol.py:211 +#: assets/const/protocol.py:219 msgid "API mode" msgstr "API 模式" @@ -1232,7 +1236,7 @@ msgstr "SSH公钥" #: common/db/models.py:36 ops/models/adhoc.py:26 ops/models/job.py:113 #: ops/models/playbook.py:26 rbac/models/role.py:37 settings/models.py:37 #: terminal/models/applet/applet.py:44 terminal/models/applet/applet.py:248 -#: terminal/models/applet/host.py:139 terminal/models/component/endpoint.py:24 +#: terminal/models/applet/host.py:141 terminal/models/component/endpoint.py:24 #: terminal/models/component/endpoint.py:102 #: terminal/models/session/session.py:46 tickets/models/comment.py:32 #: tickets/models/ticket/general.py:297 users/models/user.py:792 @@ -1361,7 +1365,7 @@ msgstr "网域" msgid "Labels" msgstr "标签管理" -#: assets/models/asset/common.py:158 assets/serializers/asset/common.py:310 +#: assets/models/asset/common.py:158 assets/serializers/asset/common.py:312 #: assets/serializers/asset/host.py:11 msgid "Gathered info" msgstr "收集资产硬件信息" @@ -1425,9 +1429,9 @@ msgstr "资产自动化任务" #: assets/models/automations/base.py:113 audits/models.py:199 #: audits/serializers.py:50 ops/models/base.py:49 ops/models/job.py:186 -#: terminal/models/applet/applet.py:247 terminal/models/applet/host.py:136 +#: terminal/models/applet/applet.py:247 terminal/models/applet/host.py:138 #: terminal/models/component/status.py:30 terminal/serializers/applet.py:18 -#: terminal/serializers/applet_host.py:107 tickets/models/ticket/general.py:283 +#: terminal/serializers/applet_host.py:108 tickets/models/ticket/general.py:283 #: tickets/serializers/super_ticket.py:13 #: tickets/serializers/ticket/ticket.py:20 xpack/plugins/cloud/models.py:164 #: xpack/plugins/cloud/models.py:216 @@ -1693,19 +1697,19 @@ msgid "Node path" msgstr "节点路径" #: assets/serializers/asset/common.py:145 -#: assets/serializers/asset/common.py:311 +#: assets/serializers/asset/common.py:313 msgid "Auto info" msgstr "自动化信息" -#: assets/serializers/asset/common.py:234 +#: assets/serializers/asset/common.py:236 msgid "Platform not exist" msgstr "平台不存在" -#: assets/serializers/asset/common.py:270 +#: assets/serializers/asset/common.py:272 msgid "port out of range (0-65535)" msgstr "端口超出范围 (0-65535)" -#: assets/serializers/asset/common.py:277 +#: assets/serializers/asset/common.py:279 msgid "Protocol is required: {}" msgstr "协议是必填的: {}" @@ -2006,7 +2010,7 @@ msgid "Change password" msgstr "改密" #: audits/const.py:35 settings/serializers/terminal.py:6 -#: terminal/models/applet/host.py:25 terminal/models/component/terminal.py:163 +#: terminal/models/applet/host.py:26 terminal/models/component/terminal.py:163 #: terminal/serializers/session.py:46 terminal/serializers/session.py:55 msgid "Terminal" msgstr "终端" @@ -2023,7 +2027,7 @@ msgstr "会话日志" msgid "Login log" msgstr "登录日志" -#: audits/const.py:43 terminal/models/applet/host.py:140 +#: audits/const.py:43 terminal/models/applet/host.py:142 #: terminal/models/component/task.py:24 msgid "Task" msgstr "任务" @@ -2232,19 +2236,19 @@ msgstr "不允许使用可重复使用的连接令牌,未启用全局设置" msgid "Anonymous account is not supported for this asset" msgstr "匿名账号不支持当前资产" -#: authentication/api/connection_token.py:323 +#: authentication/api/connection_token.py:320 msgid "Account not found" msgstr "账号未找到" -#: authentication/api/connection_token.py:326 +#: authentication/api/connection_token.py:323 msgid "Permission expired" msgstr "授权已过期" -#: authentication/api/connection_token.py:340 +#: authentication/api/connection_token.py:337 msgid "ACL action is reject: {}({})" msgstr "ACL 动作是拒绝: {}({})" -#: authentication/api/connection_token.py:344 +#: authentication/api/connection_token.py:341 msgid "ACL action is review" msgstr "ACL 动作是复核" @@ -2686,11 +2690,11 @@ msgstr "没有用户或用户失效" msgid "No asset or inactive asset" msgstr "没有资产或资产未激活" -#: authentication/models/connection_token.py:269 +#: authentication/models/connection_token.py:280 msgid "Can view super connection token secret" msgstr "可以查看超级连接令牌密文" -#: authentication/models/connection_token.py:271 +#: authentication/models/connection_token.py:282 msgid "Super connection token" msgstr "超级连接令牌" @@ -4194,7 +4198,7 @@ msgid "My assets" msgstr "我的资产" #: rbac/tree.py:56 terminal/models/applet/applet.py:51 -#: terminal/models/applet/applet.py:244 terminal/models/applet/host.py:28 +#: terminal/models/applet/applet.py:244 terminal/models/applet/host.py:29 #: terminal/serializers/applet.py:15 msgid "Applet" msgstr "远程应用" @@ -5655,7 +5659,7 @@ msgstr "输出" msgid "Risk level" msgstr "风险等级" -#: terminal/connect_methods.py:34 +#: terminal/connect_methods.py:35 msgid "DB Client" msgstr "数据库客户端" @@ -5760,28 +5764,36 @@ msgstr "只支持自定义平台" msgid "Missing type in platform.yml" msgstr "在 platform.yml 中缺少类型" -#: terminal/models/applet/applet.py:246 terminal/models/applet/host.py:34 -#: terminal/models/applet/host.py:134 +#: terminal/models/applet/applet.py:246 terminal/models/applet/host.py:35 +#: terminal/models/applet/host.py:136 msgid "Hosting" msgstr "宿主机" -#: terminal/models/applet/host.py:19 terminal/serializers/applet_host.py:57 +#: terminal/models/applet/host.py:18 terminal/serializers/applet_host.py:57 msgid "Deploy options" msgstr "部署参数" +#: terminal/models/applet/host.py:19 +msgid "Auto create accounts" +msgstr "自动创建账号" + #: terminal/models/applet/host.py:20 +msgid "Accounts create amount" +msgstr "创建账号数量" + +#: terminal/models/applet/host.py:21 msgid "Inited" msgstr "已初始化" -#: terminal/models/applet/host.py:21 +#: terminal/models/applet/host.py:22 msgid "Date inited" msgstr "初始化日期" -#: terminal/models/applet/host.py:22 +#: terminal/models/applet/host.py:23 msgid "Date synced" msgstr "同步日期" -#: terminal/models/applet/host.py:135 +#: terminal/models/applet/host.py:137 msgid "Initial" msgstr "初始化" @@ -7778,6 +7790,9 @@ msgstr "旗舰版" msgid "Community edition" msgstr "社区版" +#~ msgid "SFTP enabled" +#~ msgstr "SFTP 已启用" + #~ msgid "Item" #~ msgstr "项目" diff --git a/apps/perms/migrations/0015_auto_20200929_1728.py b/apps/perms/migrations/0015_auto_20200929_1728.py index c241a2f71..9b8388c3b 100644 --- a/apps/perms/migrations/0015_auto_20200929_1728.py +++ b/apps/perms/migrations/0015_auto_20200929_1728.py @@ -14,12 +14,12 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='assetpermission', name='user_groups', - field=models.ManyToManyField(blank=True, related_name='assetpermissions', to='users.UserGroup', verbose_name='User group'), + field=models.ManyToManyField(blank=True, related_name='%(class)ss', to='users.usergroup', verbose_name='User group'), ), migrations.AlterField( model_name='assetpermission', name='users', - field=models.ManyToManyField(blank=True, related_name='assetpermissions', to=settings.AUTH_USER_MODEL, verbose_name='User'), + field=models.ManyToManyField(blank=True, related_name='%(class)ss', to=settings.AUTH_USER_MODEL, verbose_name='User'), ), migrations.AlterField( model_name='databaseapppermission', diff --git a/apps/terminal/migrations/0064_auto_20230728_1001.py b/apps/terminal/migrations/0064_auto_20230728_1001.py new file mode 100644 index 000000000..0610f174f --- /dev/null +++ b/apps/terminal/migrations/0064_auto_20230728_1001.py @@ -0,0 +1,23 @@ +# Generated by Django 4.1.10 on 2023-07-28 02:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('terminal', '0063_auto_20230621_1133'), + ] + + operations = [ + migrations.AddField( + model_name='applethost', + name='accounts_create_amount', + field=models.IntegerField(default=100, verbose_name='Accounts create amount'), + ), + migrations.AddField( + model_name='applethost', + name='auto_create_accounts', + field=models.BooleanField(default=True, verbose_name='Auto create accounts'), + ), + ] diff --git a/apps/terminal/models/applet/host.py b/apps/terminal/models/applet/host.py index b0e7c478c..a4945a890 100644 --- a/apps/terminal/models/applet/host.py +++ b/apps/terminal/models/applet/host.py @@ -1,4 +1,3 @@ -import os from collections import defaultdict from django.db import models @@ -17,6 +16,8 @@ __all__ = ['AppletHost', 'AppletHostDeployment'] class AppletHost(Host): deploy_options = models.JSONField(default=dict, verbose_name=_('Deploy options')) + auto_create_accounts = models.BooleanField(default=True, verbose_name=_('Auto create accounts')) + accounts_create_amount = models.IntegerField(default=100, verbose_name=_('Accounts create amount')) inited = models.BooleanField(default=False, verbose_name=_('Inited')) date_inited = models.DateTimeField(null=True, blank=True, verbose_name=_('Date inited')) date_synced = models.DateTimeField(null=True, blank=True, verbose_name=_('Date synced')) @@ -84,13 +85,14 @@ class AppletHost(Host): return random_string(16, special_char=True) def generate_accounts(self): + if not self.auto_create_accounts: + return self.generate_public_accounts() self.generate_private_accounts() def generate_public_accounts(self): - public_amount = int(os.getenv('TERMINAL_ACCOUNTS_AMOUNT', 100)) now_count = self.accounts.filter(privileged=False, username__startswith='jms').count() - need = public_amount - now_count + need = self.accounts_create_amount - now_count accounts = [] account_model = self.accounts.model diff --git a/apps/terminal/serializers/applet_host.py b/apps/terminal/serializers/applet_host.py index 392b2e2e3..59b87ca9d 100644 --- a/apps/terminal/serializers/applet_host.py +++ b/apps/terminal/serializers/applet_host.py @@ -62,6 +62,7 @@ class AppletHostSerializer(HostSerializer): class Meta(HostSerializer.Meta): model = AppletHost fields = HostSerializer.Meta.fields + [ + 'auto_create_accounts', 'accounts_create_amount', 'load', 'date_synced', 'deploy_options' ] extra_kwargs = { diff --git a/apps/terminal/signal_handlers/applet.py b/apps/terminal/signal_handlers/applet.py index 4fe390b8e..912510901 100644 --- a/apps/terminal/signal_handlers/applet.py +++ b/apps/terminal/signal_handlers/applet.py @@ -23,8 +23,9 @@ def on_applet_host_create(sender, instance, created=False, **kwargs): applets = Applet.objects.all() instance.applets.set(applets) - applet_host_generate_accounts.delay(instance.id) applet_host_change_pub_sub.publish(True) + if instance.auto_create_accounts: + applet_host_generate_accounts.delay(instance.id) @receiver(post_save, sender=User) @@ -35,6 +36,8 @@ def on_user_create_create_account(sender, instance, created=False, **kwargs): with tmp_to_builtin_org(system=1): applet_hosts = AppletHost.objects.all() for host in applet_hosts: + if not host.auto_create_accounts: + continue host.generate_private_accounts_by_usernames([instance.username]) @@ -57,7 +60,6 @@ def on_applet_create(sender, instance, created=False, **kwargs): return hosts = AppletHost.objects.all() instance.hosts.set(hosts) - applet_host_change_pub_sub.publish(True)