diff --git a/apps/locale/ja/LC_MESSAGES/django.po b/apps/locale/ja/LC_MESSAGES/django.po index 4909e19e5..d6f806295 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-08-10 17:27+0800\n" +"POT-Creation-Date: 2023-08-10 18:22+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -289,7 +289,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:221 #: ops/templates/ops/celery_task_log.html:75 -#: perms/models/asset_permission.py:72 terminal/models/applet/host.py:139 +#: perms/models/asset_permission.py:72 terminal/models/applet/host.py:140 #: terminal/models/session/session.py:44 #: tickets/models/ticket/apply_application.py:30 #: tickets/models/ticket/apply_asset.py:19 @@ -418,7 +418,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:222 -#: terminal/models/applet/host.py:140 +#: terminal/models/applet/host.py:141 msgid "Date finished" msgstr "終了日" @@ -762,7 +762,7 @@ msgstr "" #: assets/models/group.py:20 common/db/models.py:36 ops/models/adhoc.py:26 #: ops/models/job.py:138 ops/models/playbook.py:31 rbac/models/role.py:37 #: settings/models.py:37 terminal/models/applet/applet.py:44 -#: terminal/models/applet/applet.py:284 terminal/models/applet/host.py:141 +#: terminal/models/applet/applet.py:284 terminal/models/applet/host.py:142 #: terminal/models/component/endpoint.py:24 #: terminal/models/component/endpoint.py:104 #: terminal/models/session/session.py:46 tickets/models/comment.py:32 @@ -1530,7 +1530,7 @@ msgstr "アセットの自動化タスク" #: assets/models/automations/base.py:113 audits/models.py:199 #: audits/serializers.py:50 ops/models/base.py:49 ops/models/job.py:213 -#: terminal/models/applet/applet.py:283 terminal/models/applet/host.py:138 +#: terminal/models/applet/applet.py:283 terminal/models/applet/host.py:139 #: terminal/models/component/status.py:30 terminal/serializers/applet.py:18 #: terminal/serializers/applet_host.py:115 tickets/models/ticket/general.py:283 #: tickets/serializers/super_ticket.py:13 @@ -2138,7 +2138,7 @@ msgstr "セッションログ" msgid "Login log" msgstr "ログインログ" -#: audits/const.py:43 terminal/models/applet/host.py:142 +#: audits/const.py:43 terminal/models/applet/host.py:143 #: terminal/models/component/task.py:22 msgid "Task" msgstr "タスク" @@ -6025,7 +6025,7 @@ msgid "Missing type in platform.yml" msgstr "platform.ymlにタイプがありません" #: terminal/models/applet/applet.py:282 terminal/models/applet/host.py:35 -#: terminal/models/applet/host.py:136 +#: terminal/models/applet/host.py:137 msgid "Hosting" msgstr "ホスト マシン" @@ -6053,7 +6053,7 @@ msgstr "初期化日" msgid "Date synced" msgstr "同期日" -#: terminal/models/applet/host.py:137 +#: terminal/models/applet/host.py:138 msgid "Initial" msgstr "初期化" @@ -6962,7 +6962,11 @@ msgstr "無効な承認アクション" msgid "This user is not authorized to approve this ticket" msgstr "このユーザーはこの作業指示を承認する権限がありません" -#: users/api/user.py:190 +#: users/api/user.py:141 +msgid "Can not invite self" +msgstr "自分自身を招待することはできません" + +#: users/api/user.py:194 msgid "Could not reset self otp, use profile reset instead" msgstr "自己otpをリセットできませんでした、代わりにプロファイルリセットを使用" diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index b03c3a1ad..3c1119e4c 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-08-10 17:27+0800\n" +"POT-Creation-Date: 2023-08-10 18:22+0800\n" "PO-Revision-Date: 2021-05-20 10:54+0800\n" "Last-Translator: ibuler \n" "Language-Team: JumpServer team\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:221 #: ops/templates/ops/celery_task_log.html:75 -#: perms/models/asset_permission.py:72 terminal/models/applet/host.py:139 +#: perms/models/asset_permission.py:72 terminal/models/applet/host.py:140 #: terminal/models/session/session.py:44 #: tickets/models/ticket/apply_application.py:30 #: tickets/models/ticket/apply_asset.py:19 @@ -417,7 +417,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:222 -#: terminal/models/applet/host.py:140 +#: terminal/models/applet/host.py:141 msgid "Date finished" msgstr "结束日期" @@ -762,7 +762,7 @@ msgstr "" #: assets/models/group.py:20 common/db/models.py:36 ops/models/adhoc.py:26 #: ops/models/job.py:138 ops/models/playbook.py:31 rbac/models/role.py:37 #: settings/models.py:37 terminal/models/applet/applet.py:44 -#: terminal/models/applet/applet.py:284 terminal/models/applet/host.py:141 +#: terminal/models/applet/applet.py:284 terminal/models/applet/host.py:142 #: terminal/models/component/endpoint.py:24 #: terminal/models/component/endpoint.py:104 #: terminal/models/session/session.py:46 tickets/models/comment.py:32 @@ -1528,7 +1528,7 @@ msgstr "资产自动化任务" #: assets/models/automations/base.py:113 audits/models.py:199 #: audits/serializers.py:50 ops/models/base.py:49 ops/models/job.py:213 -#: terminal/models/applet/applet.py:283 terminal/models/applet/host.py:138 +#: terminal/models/applet/applet.py:283 terminal/models/applet/host.py:139 #: terminal/models/component/status.py:30 terminal/serializers/applet.py:18 #: terminal/serializers/applet_host.py:115 tickets/models/ticket/general.py:283 #: tickets/serializers/super_ticket.py:13 @@ -2127,7 +2127,7 @@ msgstr "会话日志" msgid "Login log" msgstr "登录日志" -#: audits/const.py:43 terminal/models/applet/host.py:142 +#: audits/const.py:43 terminal/models/applet/host.py:143 #: terminal/models/component/task.py:22 msgid "Task" msgstr "任务" @@ -5928,7 +5928,7 @@ msgid "Missing type in platform.yml" msgstr "在 platform.yml 中缺少类型" #: terminal/models/applet/applet.py:282 terminal/models/applet/host.py:35 -#: terminal/models/applet/host.py:136 +#: terminal/models/applet/host.py:137 msgid "Hosting" msgstr "宿主机" @@ -5956,7 +5956,7 @@ msgstr "初始化日期" msgid "Date synced" msgstr "同步日期" -#: terminal/models/applet/host.py:137 +#: terminal/models/applet/host.py:138 msgid "Initial" msgstr "初始化" @@ -6853,7 +6853,11 @@ msgstr "无效的审批动作" msgid "This user is not authorized to approve this ticket" msgstr "此用户无权审批此工单" -#: users/api/user.py:190 +#: users/api/user.py:141 +msgid "Can not invite self" +msgstr "不能邀请自己" + +#: users/api/user.py:194 msgid "Could not reset self otp, use profile reset instead" msgstr "不能在该页面重置 MFA 多因子认证, 请去个人信息页面重置" diff --git a/apps/perms/api/user_group_permission.py b/apps/perms/api/user_group_permission.py index 850d1385b..dcc208e99 100644 --- a/apps/perms/api/user_group_permission.py +++ b/apps/perms/api/user_group_permission.py @@ -47,11 +47,9 @@ class UserGroupGrantedAssetsApi(ListAPIView): granted_q |= Q(granted_by_permissions__id__in=asset_perm_ids) - assets = Asset.objects.filter( - granted_q - ).distinct().only( - *self.only_fields - ) + assets = Asset.objects.filter(granted_q) \ + .only(*self.only_fields) \ + .distinct() return assets diff --git a/apps/terminal/models/applet/host.py b/apps/terminal/models/applet/host.py index a4945a890..23af7f5ac 100644 --- a/apps/terminal/models/applet/host.py +++ b/apps/terminal/models/applet/host.py @@ -125,6 +125,7 @@ class AppletHost(Host): from users.models import User usernames = User.objects \ .filter(is_active=True, is_service_account=False) \ + .exclude(username__startswith='[') \ .values_list('username', flat=True) account_usernames = self.accounts.all().values_list('username', flat=True) account_usernames = [username[3:] for username in account_usernames if username.startswith('js_')] diff --git a/apps/users/api/__init__.py b/apps/users/api/__init__.py index d5db61888..6231e874b 100644 --- a/apps/users/api/__init__.py +++ b/apps/users/api/__init__.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # -from .user import * from .group import * from .profile import * -from .service_account import * from .relation import * +from .service import * +from .user import * diff --git a/apps/users/api/service_account.py b/apps/users/api/service.py similarity index 100% rename from apps/users/api/service_account.py rename to apps/users/api/service.py diff --git a/apps/users/api/user.py b/apps/users/api/user.py index e0bc288c8..524571025 100644 --- a/apps/users/api/user.py +++ b/apps/users/api/user.py @@ -136,6 +136,10 @@ class UserViewSet(CommonApiMixin, UserQuerysetMixin, SuggestionMixin, BulkModelV users = validated_data['users'] org_roles = validated_data['org_roles'] + has_self = any([str(u.id) == str(request.user.id) for u in users]) + if has_self and not request.user.is_superuser: + error = {"error": _("Can not invite self")} + return Response(error, status=400) for user in users: user.org_roles.set(org_roles) return Response(serializer.data, status=201)