From c2b592f6fedfe2190e61563342d01941b150499a Mon Sep 17 00:00:00 2001 From: jiangweidong Date: Thu, 23 Feb 2023 10:46:59 +0800 Subject: [PATCH 01/21] =?UTF-8?q?fix:=20=E5=88=9B=E5=BB=BA=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=92=8C=E9=AA=8C=E8=AF=81=E8=B4=A6=E5=8F=B7=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=9A=84Activity=E6=97=A5=E5=BF=97=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/accounts/tasks/verify_account.py | 2 +- apps/audits/signal_handlers/activity_log.py | 4 ++-- apps/common/tasks.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/accounts/tasks/verify_account.py b/apps/accounts/tasks/verify_account.py index efc6bb09d..5f221fcd6 100644 --- a/apps/accounts/tasks/verify_account.py +++ b/apps/accounts/tasks/verify_account.py @@ -47,7 +47,7 @@ def verify_accounts_connectivity_util(accounts, task_name): @shared_task( queue="ansible", verbose_name=_('Verify asset account availability'), - activity_callback=lambda self, account_ids, asset_ids: (account_ids, None) + activity_callback=lambda self, account_ids, *args, **kwargs: (account_ids, None) ) def verify_accounts_connectivity_task(account_ids): from accounts.models import Account, VerifyAccountAutomation diff --git a/apps/audits/signal_handlers/activity_log.py b/apps/audits/signal_handlers/activity_log.py index 430b25002..4b41d2d1d 100644 --- a/apps/audits/signal_handlers/activity_log.py +++ b/apps/audits/signal_handlers/activity_log.py @@ -57,8 +57,8 @@ class ActivityLogHandler: resource_ids, org_id, user = data + ('',) * (3 - len(data)) if not user: user = str(current_request.user) if current_request else 'System' - if org_id is None: - org_id = current_org.org_id + if not org_id: + org_id = current_org.id task_display = getattr(task, 'verbose_name', _('Unknown')) detail = i18n_fmt( gettext_noop('User %s perform a task for this resource: %s'), diff --git a/apps/common/tasks.py b/apps/common/tasks.py index 76616803a..b4c3d3488 100644 --- a/apps/common/tasks.py +++ b/apps/common/tasks.py @@ -10,11 +10,11 @@ from .utils import get_logger logger = get_logger(__file__) -def task_activity_callback(self, subject, message, from_email, recipient_list, **kwargs): +def task_activity_callback(self, subject, message, recipient_list, **kwargs): from users.models import User email_list = recipient_list resource_ids = list(User.objects.filter(email__in=email_list).values_list('id', flat=True)) - return resource_ids + return resource_ids, @shared_task(verbose_name=_("Send email"), activity_callback=task_activity_callback) From aaeef83d385a4ac81f3d20410f2c2bb46963d8dd Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 23 Feb 2023 11:27:03 +0800 Subject: [PATCH 02/21] perf: history account secret (#9711) Co-authored-by: feng <1304903146@qq.com> --- apps/accounts/api/account/account.py | 8 +++----- apps/rbac/const.py | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/accounts/api/account/account.py b/apps/accounts/api/account/account.py index 73540126b..64dc745f8 100644 --- a/apps/accounts/api/account/account.py +++ b/apps/accounts/api/account/account.py @@ -7,18 +7,16 @@ from accounts import serializers from accounts.filters import AccountFilterSet from accounts.models import Account from assets.models import Asset -from authentication.const import ConfirmType -from common.permissions import UserConfirmation +from common.permissions import UserConfirmation, ConfirmType from common.views.mixins import RecordViewLogMixin from orgs.mixins.api import OrgBulkModelViewSet +from rbac.permissions import RBACPermission __all__ = [ 'AccountViewSet', 'AccountSecretsViewSet', 'AccountHistoriesSecretAPI' ] -from rbac.permissions import RBACPermission - class AccountViewSet(OrgBulkModelViewSet): model = Account @@ -71,7 +69,7 @@ class AccountHistoriesSecretAPI(RecordViewLogMixin, ListAPIView): http_method_names = ['get', 'options'] permission_classes = [RBACPermission, UserConfirmation.require(ConfirmType.MFA)] rbac_perms = { - 'list': 'accounts.view_accountsecret', + 'GET': 'accounts.view_accountsecret', } def get_object(self): diff --git a/apps/rbac/const.py b/apps/rbac/const.py index 2092cd9ff..eeb09b46e 100644 --- a/apps/rbac/const.py +++ b/apps/rbac/const.py @@ -61,6 +61,8 @@ exclude_permissions = ( ('accounts', 'accountbackupexecution', 'delete,change', 'accountbackupexecution'), ('accounts', 'changesecretrecord', 'add,delete,change', 'changesecretrecord'), ('accounts', 'account', 'change', 'accountsecret'), + ('accounts', 'account', 'view', 'historyaccount'), + ('accounts', 'account', 'view', 'historyaccountsecret'), ('perms', 'userassetgrantedtreenoderelation', '*', '*'), ('perms', 'permedaccount', '*', '*'), From d4435799ac5f8b8436843b630374b98457ef3331 Mon Sep 17 00:00:00 2001 From: Bai Date: Thu, 23 Feb 2023 11:44:32 +0800 Subject: [PATCH 03/21] =?UTF-8?q?fix:=20=E6=8E=88=E6=9D=83=E8=A7=84?= =?UTF-8?q?=E5=88=99=E8=B4=A6=E5=8F=B7=E5=88=97=E8=A1=A8=E8=BF=94=E5=9B=9E?= =?UTF-8?q?asset.auto=5Finfo=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/accounts/serializers/account/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/accounts/serializers/account/account.py b/apps/accounts/serializers/account/account.py index 571d8b986..42fc8f898 100644 --- a/apps/accounts/serializers/account/account.py +++ b/apps/accounts/serializers/account/account.py @@ -77,7 +77,7 @@ class AccountAssetSerializer(serializers.ModelSerializer): class Meta: model = Asset - fields = ['id', 'name', 'address', 'type', 'category', 'platform'] + fields = ['id', 'name', 'address', 'type', 'category', 'platform', 'auto_info'] def to_internal_value(self, data): if isinstance(data, dict): From ee926cfa42191cd6a1d1163a9811401de28aa8d4 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 23 Feb 2023 15:04:07 +0800 Subject: [PATCH 04/21] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=20agent=20?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/utils/django.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/apps/common/utils/django.py b/apps/common/utils/django.py index 2c4808d16..ad8a218d8 100644 --- a/apps/common/utils/django.py +++ b/apps/common/utils/django.py @@ -85,13 +85,12 @@ def bulk_create_with_signal(cls: models.Model, items, **kwargs): def get_request_os(request): """获取请求的操作系统""" agent = request.META.get('HTTP_USER_AGENT', '').lower() - - if agent is None: - return 'unknown' - if 'windows' in agent.lower(): + + if 'windows' in agent: return 'windows' - if 'mac' in agent.lower(): + elif 'mac' in agent: return 'mac' - if 'linux' in agent.lower(): + elif 'linux' in agent: return 'linux' - return 'unknown' + else: + return 'unknown' From a20bd3acd4cda2fba08bd2186a9afee15eb9f9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B0=8F=E7=99=BD?= <296015668@qq.com> Date: Thu, 23 Feb 2023 15:48:02 +0800 Subject: [PATCH 05/21] =?UTF-8?q?perf:=20=E6=9B=B4=E6=96=B0=20quick=5Fstar?= =?UTF-8?q?t.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release-drafter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 865aa4051..110612850 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -21,7 +21,7 @@ jobs: TAG=$(basename ${GITHUB_REF}) VERSION=${TAG/v/} wget https://raw.githubusercontent.com/jumpserver/installer/master/quick_start.sh - sed -i "s@Version=.*@Version=v${VERSION}@g" quick_start.sh + sed -i "s@VERSION=dev@VERSION=v${VERSION}@g" quick_start.sh echo "::set-output name=TAG::$TAG" echo "::set-output name=VERSION::$VERSION" - name: Create Release From 3ee2bfce9a896bb0a41327c260d322f6df073c60 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 23 Feb 2023 15:58:55 +0800 Subject: [PATCH 06/21] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E6=96=B9=E5=BC=8F=20(#9716)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: ibuler --- apps/terminal/connect_methods.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/terminal/connect_methods.py b/apps/terminal/connect_methods.py index 10ecdfab5..944439ff1 100644 --- a/apps/terminal/connect_methods.py +++ b/apps/terminal/connect_methods.py @@ -148,7 +148,7 @@ class AppletMethod: class ConnectMethodUtil: - _all_methods = None + _all_methods = {} @classmethod def protocols(cls): @@ -210,7 +210,7 @@ class ConnectMethodUtil: @classmethod def refresh_methods(cls): - cls._all_methods = None + cls._all_methods = {} @classmethod def get_filtered_protocols_connect_methods(cls, os): @@ -245,8 +245,8 @@ class ConnectMethodUtil: @classmethod def get_protocols_connect_methods(cls, os): - if cls._all_methods is not None: - return cls._all_methods + if cls._all_methods.get('os'): + return cls._all_methods['os'] methods = defaultdict(list) web_methods = WebMethod.get_methods() @@ -298,5 +298,5 @@ class ConnectMethodUtil: method['component'] = TerminalType.tinker.value methods[protocol].extend(applet_methods) - cls._all_methods = methods + cls._all_methods[os] = methods return methods From d1b807bd8b8131fa0d0000778dfb4a25b1b1c098 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 23 Feb 2023 16:14:24 +0800 Subject: [PATCH 07/21] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=20account=20as?= =?UTF-8?q?set=20auto=5Finfo=20=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/accounts/serializers/account/account.py | 2 +- apps/assets/serializers/asset/common.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/accounts/serializers/account/account.py b/apps/accounts/serializers/account/account.py index 42fc8f898..a06a11fd6 100644 --- a/apps/accounts/serializers/account/account.py +++ b/apps/accounts/serializers/account/account.py @@ -119,7 +119,7 @@ class AccountSerializer(AccountSerializerCreateMixin, BaseAccountSerializer): def setup_eager_loading(cls, queryset): """ Perform necessary eager loading of data. """ queryset = queryset \ - .prefetch_related('asset', 'asset__platform') + .prefetch_related('asset', 'asset__platform', 'asset__platform__automation') return queryset diff --git a/apps/assets/serializers/asset/common.py b/apps/assets/serializers/asset/common.py index c5a9ed02d..c4f2a5da7 100644 --- a/apps/assets/serializers/asset/common.py +++ b/apps/assets/serializers/asset/common.py @@ -136,6 +136,7 @@ class AssetSerializer(BulkOrgResourceModelSerializer, WritableNestedModelSeriali read_only_fields = [ 'category', 'type', 'connectivity', 'date_verified', 'created_by', 'date_created', + 'auto_info', ] fields = fields_small + fields_fk + fields_m2m + read_only_fields extra_kwargs = { @@ -182,10 +183,10 @@ class AssetSerializer(BulkOrgResourceModelSerializer, WritableNestedModelSeriali @classmethod def setup_eager_loading(cls, queryset): """ Perform necessary eager loading of data. """ - queryset = queryset.prefetch_related('domain', 'platform') \ + queryset = queryset.prefetch_related('domain', 'nodes', 'labels', 'protocols') \ + .prefetch_related('platform', 'platform__automation') \ .annotate(category=F("platform__category")) \ .annotate(type=F("platform__type")) - queryset = queryset.prefetch_related('nodes', 'labels', 'protocols') return queryset @staticmethod From 0a5766edd32b995a0736d230819545150a268992 Mon Sep 17 00:00:00 2001 From: jiangweidong Date: Thu, 23 Feb 2023 16:20:43 +0800 Subject: [PATCH 08/21] =?UTF-8?q?fix:=20=E6=93=8D=E4=BD=9C=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=9A=84=E5=9B=BD=E9=99=85=E5=8C=96=E5=BA=94=E8=AF=A5?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=9F=A5=E8=AF=A2=E5=AF=B9=E8=B1=A1=E7=9A=84?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E5=86=B3=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/audits/backends/db.py | 2 +- apps/audits/serializers.py | 10 ++ apps/audits/signal_handlers/operate_log.py | 123 +++++++++++---------- apps/audits/utils.py | 9 -- apps/common/views/mixins.py | 15 ++- apps/settings/serializers/settings.py | 19 ++-- 6 files changed, 95 insertions(+), 83 deletions(-) diff --git a/apps/audits/backends/db.py b/apps/audits/backends/db.py index 57de654d4..0c0f46a4a 100644 --- a/apps/audits/backends/db.py +++ b/apps/audits/backends/db.py @@ -51,7 +51,7 @@ class OperateLogStore(object): for k, v in raw_diff.items(): before, after = v.split(cls.SEP, 1) diff_list.append({ - 'field': k, + 'field': _(k), 'before': before if before else _('empty'), 'after': after if after else _('empty'), }) diff --git a/apps/audits/serializers.py b/apps/audits/serializers.py index 0956f2209..e9f3bf85c 100644 --- a/apps/audits/serializers.py +++ b/apps/audits/serializers.py @@ -80,6 +80,8 @@ class OperateLogActionDetailSerializer(serializers.ModelSerializer): class OperateLogSerializer(serializers.ModelSerializer): action = LabeledChoiceField(choices=ActionChoices.choices, label=_("Action")) + resource = serializers.SerializerMethodField(label=_("Resource")) + resource_type = serializers.SerializerMethodField(label=_('Resource')) class Meta: model = models.OperateLog @@ -91,6 +93,14 @@ class OperateLogSerializer(serializers.ModelSerializer): ] fields = fields_small + @staticmethod + def get_resource_type(instance): + return _(instance.resource_type) + + @staticmethod + def get_resource(instance): + return i18n_trans(instance.resource) + class PasswordChangeLogSerializer(serializers.ModelSerializer): class Meta: diff --git a/apps/audits/signal_handlers/operate_log.py b/apps/audits/signal_handlers/operate_log.py index 7d97724cf..302e89190 100644 --- a/apps/audits/signal_handlers/operate_log.py +++ b/apps/audits/signal_handlers/operate_log.py @@ -5,6 +5,7 @@ import uuid from django.apps import apps from django.db.models.signals import post_save, pre_save, m2m_changed, pre_delete from django.dispatch import receiver +from django.utils import translation from audits.handler import ( get_instance_current_with_cache_diff, cache_instance_before_data, @@ -29,39 +30,40 @@ def on_m2m_changed(sender, action, instance, reverse, model, pk_set, **kwargs): if not instance: return - resource_type = instance._meta.verbose_name - current_instance = model_to_dict(instance, include_model_fields=False) + with translation.override('en'): + resource_type = instance._meta.verbose_name + current_instance = model_to_dict(instance, include_model_fields=False) - instance_id = current_instance.get('id') - log_id, before_instance = get_instance_dict_from_cache(instance_id) + instance_id = current_instance.get('id') + log_id, before_instance = get_instance_dict_from_cache(instance_id) - field_name = str(model._meta.verbose_name) - objs = model.objects.filter(pk__in=pk_set) - objs_display = [str(o) for o in objs] - action = M2M_ACTION[action] - changed_field = current_instance.get(field_name, []) + field_name = str(model._meta.verbose_name) + objs = model.objects.filter(pk__in=pk_set) + objs_display = [str(o) for o in objs] + action = M2M_ACTION[action] + changed_field = current_instance.get(field_name, []) - after, before, before_value = None, None, None - if action == ActionChoices.create: - before_value = list(set(changed_field) - set(objs_display)) - elif action == ActionChoices.delete: - before_value = list( - set(changed_field).symmetric_difference(set(objs_display)) + after, before, before_value = None, None, None + if action == ActionChoices.create: + before_value = list(set(changed_field) - set(objs_display)) + elif action == ActionChoices.delete: + before_value = list( + set(changed_field).symmetric_difference(set(objs_display)) + ) + + if changed_field: + after = {field_name: changed_field} + if before_value: + before = {field_name: before_value} + + if sorted(str(before)) == sorted(str(after)): + return + + create_or_update_operate_log( + ActionChoices.update, resource_type, + resource=instance, log_id=log_id, before=before, after=after ) - if changed_field: - after = {field_name: changed_field} - if before_value: - before = {field_name: before_value} - - if sorted(str(before)) == sorted(str(after)): - return - - create_or_update_operate_log( - ActionChoices.update, resource_type, - resource=instance, log_id=log_id, before=before, after=after - ) - def signal_of_operate_log_whether_continue( sender, instance, created, update_fields=None @@ -93,18 +95,18 @@ def on_object_pre_create_or_update( ) if not ok: return + with translation.override('en'): + # users.PrivateToken Model 没有 id 有 pk字段 + instance_id = getattr(instance, 'id', getattr(instance, 'pk', None)) + instance_before_data = {'id': instance_id} + raw_instance = type(instance).objects.filter(pk=instance_id).first() - # users.PrivateToken Model 没有 id 有 pk字段 - instance_id = getattr(instance, 'id', getattr(instance, 'pk', None)) - instance_before_data = {'id': instance_id} - raw_instance = type(instance).objects.filter(pk=instance_id).first() - - if raw_instance: - instance_before_data = model_to_dict(raw_instance) - operate_log_id = str(uuid.uuid4()) - instance_before_data['operate_log_id'] = operate_log_id - setattr(instance, 'operate_log_id', operate_log_id) - cache_instance_before_data(instance_before_data) + if raw_instance: + instance_before_data = model_to_dict(raw_instance) + operate_log_id = str(uuid.uuid4()) + instance_before_data['operate_log_id'] = operate_log_id + setattr(instance, 'operate_log_id', operate_log_id) + cache_instance_before_data(instance_before_data) @receiver(post_save) @@ -116,23 +118,23 @@ def on_object_created_or_update( ) if not ok: return + with translation.override('en'): + log_id, before, after = None, None, None + if created: + action = ActionChoices.create + after = model_to_dict(instance) + log_id = getattr(instance, 'operate_log_id', None) + else: + action = ActionChoices.update + current_instance = model_to_dict(instance) + log_id, before, after = get_instance_current_with_cache_diff(current_instance) - log_id, before, after = None, None, None - if created: - action = ActionChoices.create - after = model_to_dict(instance) - log_id = getattr(instance, 'operate_log_id', None) - else: - action = ActionChoices.update - current_instance = model_to_dict(instance) - log_id, before, after = get_instance_current_with_cache_diff(current_instance) - - resource_type = sender._meta.verbose_name - object_name = sender._meta.object_name - create_or_update_operate_log( - action, resource_type, resource=instance, log_id=log_id, - before=before, after=after, object_name=object_name - ) + resource_type = sender._meta.verbose_name + object_name = sender._meta.object_name + create_or_update_operate_log( + action, resource_type, resource=instance, log_id=log_id, + before=before, after=after, object_name=object_name + ) @receiver(pre_delete) @@ -141,11 +143,12 @@ def on_object_delete(sender, instance=None, **kwargs): if not ok: return - resource_type = sender._meta.verbose_name - create_or_update_operate_log( - ActionChoices.delete, resource_type, - resource=instance, before=model_to_dict(instance) - ) + with translation.override('en'): + resource_type = sender._meta.verbose_name + create_or_update_operate_log( + ActionChoices.delete, resource_type, + resource=instance, before=model_to_dict(instance) + ) @receiver(django_ready) diff --git a/apps/audits/utils.py b/apps/audits/utils.py index 877c75813..d069a6d26 100644 --- a/apps/audits/utils.py +++ b/apps/audits/utils.py @@ -45,15 +45,6 @@ def write_login_log(*args, **kwargs): UserLoginLog.objects.create(**kwargs) -def get_resource_display(resource): - resource_display = str(resource) - setting_serializer = SettingsSerializer() - label = setting_serializer.get_field_label(resource_display) - if label is not None: - resource_display = label - return resource_display - - def _get_instance_field_value( instance, include_model_fields, model_need_continue_fields, exclude_fields=None diff --git a/apps/common/views/mixins.py b/apps/common/views/mixins.py index b0c38dee2..cb2e402c8 100644 --- a/apps/common/views/mixins.py +++ b/apps/common/views/mixins.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # +from django.utils import translation from django.utils.translation import ugettext_lazy as _ from django.contrib.auth.mixins import UserPassesTestMixin from django.http.response import JsonResponse @@ -66,8 +67,9 @@ class RecordViewLogMixin: def list(self, request, *args, **kwargs): response = super().list(request, *args, **kwargs) - resource_display = self.get_resource_display(request) - resource_type = self.model._meta.verbose_name + with translation.override('en'): + resource_display = self.get_resource_display(request) + resource_type = self.model._meta.verbose_name create_or_update_operate_log( self.ACTION, resource_type, force=True, resource_display=resource_display @@ -76,8 +78,9 @@ class RecordViewLogMixin: def retrieve(self, request, *args, **kwargs): response = super().retrieve(request, *args, **kwargs) - resource_type = self.model._meta.verbose_name - create_or_update_operate_log( - self.ACTION, resource_type, force=True, resource=self.get_object() - ) + with translation.override('en'): + resource_type = self.model._meta.verbose_name + create_or_update_operate_log( + self.ACTION, resource_type, force=True, resource=self.get_object() + ) return response diff --git a/apps/settings/serializers/settings.py b/apps/settings/serializers/settings.py index cb6472de4..21ca6d461 100644 --- a/apps/settings/serializers/settings.py +++ b/apps/settings/serializers/settings.py @@ -1,7 +1,9 @@ # coding: utf-8 from django.core.cache import cache -from django.utils.translation import ugettext_lazy as _ +from django.utils import translation +from django.utils.translation import gettext_noop, ugettext_lazy as _ +from common.utils import i18n_fmt from .basic import BasicSettingSerializer from .other import OtherSettingSerializer from .email import EmailSettingSerializer, EmailContentSettingSerializer @@ -55,13 +57,16 @@ class SettingsSerializer( # 单次计算量不大,搞个缓存,以防操作日志大量写入时,这里影响性能 def get_field_label(self, field_name): + self.fields_label_mapping = cache.get(self.CACHE_KEY, None) if self.fields_label_mapping is None: self.fields_label_mapping = {} - for subclass in SettingsSerializer.__bases__: - prefix = getattr(subclass, 'PREFIX_TITLE', _('Setting')) - fields = subclass().get_fields() - for name, item in fields.items(): - label = '[%s] %s' % (prefix, getattr(item, 'label', '')) - self.fields_label_mapping[name] = label + with translation.override('en'): + for subclass in SettingsSerializer.__bases__: + prefix = getattr(subclass, 'PREFIX_TITLE', _('Setting')) + fields = subclass().get_fields() + for name, item in fields.items(): + label = getattr(item, 'label', '') + detail = i18n_fmt(gettext_noop('[%s] %s'), prefix, label) + self.fields_label_mapping[name] = detail cache.set(self.CACHE_KEY, self.fields_label_mapping, 3600 * 24) return self.fields_label_mapping.get(field_name) From 9c599fd1f43e127ac4ac65a9060f8489a45028a8 Mon Sep 17 00:00:00 2001 From: jiangweidong Date: Thu, 23 Feb 2023 16:25:02 +0800 Subject: [PATCH 09/21] =?UTF-8?q?fix:=20=E6=9B=B4=E6=94=B9label?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/audits/serializers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/audits/serializers.py b/apps/audits/serializers.py index e9f3bf85c..c6029e517 100644 --- a/apps/audits/serializers.py +++ b/apps/audits/serializers.py @@ -81,7 +81,7 @@ class OperateLogActionDetailSerializer(serializers.ModelSerializer): class OperateLogSerializer(serializers.ModelSerializer): action = LabeledChoiceField(choices=ActionChoices.choices, label=_("Action")) resource = serializers.SerializerMethodField(label=_("Resource")) - resource_type = serializers.SerializerMethodField(label=_('Resource')) + resource_type = serializers.SerializerMethodField(label=_('Resource Type')) class Meta: model = models.OperateLog From e1a1e838bff6b5bc1c35bedbb9263701a8345b10 Mon Sep 17 00:00:00 2001 From: jiangweidong Date: Thu, 23 Feb 2023 16:38:44 +0800 Subject: [PATCH 10/21] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E8=AE=BE=E7=BD=AE=E7=B1=BB=E7=9A=84=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E4=BC=9A=E7=9B=B4=E6=8E=A5=E7=BF=BB=E8=AF=91=E6=88=90=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/settings/serializers/auth/base.py | 2 +- apps/settings/serializers/auth/cas.py | 2 +- apps/settings/serializers/auth/dingtalk.py | 2 +- apps/settings/serializers/auth/feishu.py | 2 +- apps/settings/serializers/auth/ldap.py | 2 +- apps/settings/serializers/auth/oauth2.py | 2 +- apps/settings/serializers/auth/oidc.py | 2 +- apps/settings/serializers/auth/radius.py | 2 +- apps/settings/serializers/auth/saml2.py | 2 +- apps/settings/serializers/auth/sso.py | 2 +- apps/settings/serializers/auth/wecom.py | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/settings/serializers/auth/base.py b/apps/settings/serializers/auth/base.py index 24abb372e..abc1ab8b0 100644 --- a/apps/settings/serializers/auth/base.py +++ b/apps/settings/serializers/auth/base.py @@ -7,7 +7,7 @@ __all__ = [ class AuthSettingSerializer(serializers.Serializer): - PREFIX_TITLE = '%s-%s' % (_('Authentication'), _('Basic')) + PREFIX_TITLE = _('Authentication') AUTH_CAS = serializers.BooleanField(required=False, label=_('CAS Auth')) AUTH_OPENID = serializers.BooleanField(required=False, label=_('OPENID Auth')) diff --git a/apps/settings/serializers/auth/cas.py b/apps/settings/serializers/auth/cas.py index 4814a92bb..4cfa07d1b 100644 --- a/apps/settings/serializers/auth/cas.py +++ b/apps/settings/serializers/auth/cas.py @@ -7,7 +7,7 @@ __all__ = [ class CASSettingSerializer(serializers.Serializer): - PREFIX_TITLE = '%s-%s' % (_('Authentication'), _('CAS')) + PREFIX_TITLE = _('CAS') AUTH_CAS = serializers.BooleanField(required=False, label=_('Enable CAS Auth')) CAS_SERVER_URL = serializers.CharField(required=False, max_length=1024, label=_('Server url')) diff --git a/apps/settings/serializers/auth/dingtalk.py b/apps/settings/serializers/auth/dingtalk.py index 8df199eea..4ec7814a1 100644 --- a/apps/settings/serializers/auth/dingtalk.py +++ b/apps/settings/serializers/auth/dingtalk.py @@ -7,7 +7,7 @@ __all__ = ['DingTalkSettingSerializer'] class DingTalkSettingSerializer(serializers.Serializer): - PREFIX_TITLE = '%s-%s' % (_('Authentication'), _('DingTalk')) + PREFIX_TITLE = _('DingTalk') DINGTALK_AGENTID = serializers.CharField(max_length=256, required=True, label='AgentId') DINGTALK_APPKEY = serializers.CharField(max_length=256, required=True, label='AppKey') diff --git a/apps/settings/serializers/auth/feishu.py b/apps/settings/serializers/auth/feishu.py index 580cdb12a..1443a244c 100644 --- a/apps/settings/serializers/auth/feishu.py +++ b/apps/settings/serializers/auth/feishu.py @@ -7,7 +7,7 @@ __all__ = ['FeiShuSettingSerializer'] class FeiShuSettingSerializer(serializers.Serializer): - PREFIX_TITLE = '%s-%s' % (_('Authentication'), _('FeiShu')) + PREFIX_TITLE = _('FeiShu') FEISHU_APP_ID = serializers.CharField(max_length=256, required=True, label='App ID') FEISHU_APP_SECRET = EncryptedField(max_length=256, required=False, label='App Secret') diff --git a/apps/settings/serializers/auth/ldap.py b/apps/settings/serializers/auth/ldap.py index 6d4e892d6..c530aa80c 100644 --- a/apps/settings/serializers/auth/ldap.py +++ b/apps/settings/serializers/auth/ldap.py @@ -36,7 +36,7 @@ class LDAPUserSerializer(serializers.Serializer): class LDAPSettingSerializer(serializers.Serializer): # encrypt_fields 现在使用 write_only 来判断了 - PREFIX_TITLE = '%s-%s' % (_('Authentication'), _('LDAP')) + PREFIX_TITLE = _('LDAP') AUTH_LDAP_SERVER_URI = serializers.CharField( required=True, max_length=1024, label=_('LDAP server'), diff --git a/apps/settings/serializers/auth/oauth2.py b/apps/settings/serializers/auth/oauth2.py index 46e279969..6aaacaa5b 100644 --- a/apps/settings/serializers/auth/oauth2.py +++ b/apps/settings/serializers/auth/oauth2.py @@ -15,7 +15,7 @@ class SettingImageField(serializers.ImageField): class OAuth2SettingSerializer(serializers.Serializer): - PREFIX_TITLE = '%s-%s' % (_('Authentication'), _('OAuth2')) + PREFIX_TITLE = _('OAuth2') AUTH_OAUTH2 = serializers.BooleanField( default=False, label=_('Enable OAuth2 Auth') diff --git a/apps/settings/serializers/auth/oidc.py b/apps/settings/serializers/auth/oidc.py index f5c71d7a8..cbbcf3386 100644 --- a/apps/settings/serializers/auth/oidc.py +++ b/apps/settings/serializers/auth/oidc.py @@ -9,7 +9,7 @@ __all__ = [ class CommonSettingSerializer(serializers.Serializer): - PREFIX_TITLE = '%s-%s' % (_('Authentication'), _('OIDC')) + PREFIX_TITLE = _('OIDC') # OpenID 公有配置参数 (version <= 1.5.8 或 version >= 1.5.8) BASE_SITE_URL = serializers.CharField( required=False, allow_null=True, allow_blank=True, diff --git a/apps/settings/serializers/auth/radius.py b/apps/settings/serializers/auth/radius.py index c9eb2e83e..54098c3d0 100644 --- a/apps/settings/serializers/auth/radius.py +++ b/apps/settings/serializers/auth/radius.py @@ -10,7 +10,7 @@ __all__ = ['RadiusSettingSerializer'] class RadiusSettingSerializer(serializers.Serializer): - PREFIX_TITLE = '%s-%s' % (_('Authentication'), _('Radius')) + PREFIX_TITLE = _('Radius') AUTH_RADIUS = serializers.BooleanField(required=False, label=_('Enable Radius Auth')) RADIUS_SERVER = serializers.CharField(required=False, allow_blank=True, max_length=1024, label=_('Host')) diff --git a/apps/settings/serializers/auth/saml2.py b/apps/settings/serializers/auth/saml2.py index e98a8bbe5..d89f30577 100644 --- a/apps/settings/serializers/auth/saml2.py +++ b/apps/settings/serializers/auth/saml2.py @@ -8,7 +8,7 @@ __all__ = [ class SAML2SettingSerializer(serializers.Serializer): - PREFIX_TITLE = '%s-%s' % (_('Authentication'), _('SAML2')) + PREFIX_TITLE = _('SAML2') AUTH_SAML2 = serializers.BooleanField( default=False, required=False, label=_('Enable SAML2 Auth') diff --git a/apps/settings/serializers/auth/sso.py b/apps/settings/serializers/auth/sso.py index 0dad5e25b..0f7a7cef7 100644 --- a/apps/settings/serializers/auth/sso.py +++ b/apps/settings/serializers/auth/sso.py @@ -7,7 +7,7 @@ __all__ = [ class SSOSettingSerializer(serializers.Serializer): - PREFIX_TITLE = '%s-%s' % (_('Authentication'), _('SSO')) + PREFIX_TITLE = _('SSO') AUTH_SSO = serializers.BooleanField( required=False, label=_('Enable SSO auth'), diff --git a/apps/settings/serializers/auth/wecom.py b/apps/settings/serializers/auth/wecom.py index a0b216a9d..462b17db6 100644 --- a/apps/settings/serializers/auth/wecom.py +++ b/apps/settings/serializers/auth/wecom.py @@ -7,7 +7,7 @@ __all__ = ['WeComSettingSerializer'] class WeComSettingSerializer(serializers.Serializer): - PREFIX_TITLE = '%s-%s' % (_('Authentication'), _('WeCom')) + PREFIX_TITLE = _('WeCom') WECOM_CORPID = serializers.CharField(max_length=256, required=True, label='corpid') WECOM_AGENTID = serializers.CharField(max_length=256, required=True, label='agentid') From b2f38c22186db15af411a4c349fc1ee7f4774de4 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 23 Feb 2023 17:01:24 +0800 Subject: [PATCH 11/21] =?UTF-8?q?perf:=20=E5=A2=9E=E5=8A=A0=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=B8=85=E7=90=86=E5=83=B5=E5=B0=B8?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=20(#9714)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * perf: 增加定时任务清理僵尸作业 * perf: 优化代码结构 * fix: 修改翻译 * perf: 延长清理间隔时间 * perf: 添加优先级括号 --------- Co-authored-by: Aaron3S --- apps/locale/ja/LC_MESSAGES/django.po | 66 +++++++++++++++------------- apps/locale/zh/LC_MESSAGES/django.po | 66 +++++++++++++++------------- apps/ops/models/job.py | 13 ++++++ apps/ops/tasks.py | 9 +++- 4 files changed, 91 insertions(+), 63 deletions(-) diff --git a/apps/locale/ja/LC_MESSAGES/django.po b/apps/locale/ja/LC_MESSAGES/django.po index 91c1abe30..ac6f12e6a 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-02-22 21:23+0800\n" +"POT-Creation-Date: 2023-02-23 16:29+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -249,7 +249,7 @@ msgstr "アカウントバックアップ計画" #: accounts/models/automations/backup_account.py:83 #: assets/models/automations/base.py:114 audits/models.py:55 -#: ops/models/base.py:55 ops/models/celery.py:63 ops/models/job.py:186 +#: ops/models/base.py:55 ops/models/celery.py:63 ops/models/job.py:191 #: perms/models/asset_permission.py:72 terminal/models/applet/host.py:109 #: terminal/models/session/session.py:45 #: tickets/models/ticket/apply_application.py:30 @@ -371,7 +371,7 @@ msgstr "開始日" #: accounts/models/automations/change_secret.py:74 #: assets/models/automations/base.py:115 ops/models/base.py:56 -#: ops/models/celery.py:64 ops/models/job.py:187 +#: ops/models/celery.py:64 ops/models/job.py:192 #: terminal/models/applet/host.py:110 msgid "Date finished" msgstr "終了日" @@ -450,7 +450,7 @@ msgstr "アカウントの確認" #: assets/serializers/platform.py:91 assets/serializers/platform.py:136 #: authentication/serializers/connect_token_secret.py:103 ops/mixin.py:21 #: ops/models/adhoc.py:21 ops/models/celery.py:15 ops/models/celery.py:57 -#: ops/models/job.py:90 ops/models/playbook.py:23 ops/serializers/job.py:19 +#: ops/models/job.py:91 ops/models/playbook.py:23 ops/serializers/job.py:19 #: orgs/models.py:69 perms/models/asset_permission.py:56 rbac/models/role.py:29 #: settings/models.py:33 settings/serializers/sms.py:6 #: terminal/models/applet/applet.py:27 terminal/models/component/endpoint.py:12 @@ -546,7 +546,7 @@ msgstr "カテゴリ" #: assets/models/cmd_filter.py:74 assets/models/platform.py:78 #: assets/serializers/asset/common.py:122 assets/serializers/platform.py:96 #: audits/serializers.py:48 -#: authentication/serializers/connect_token_secret.py:116 ops/models/job.py:101 +#: authentication/serializers/connect_token_secret.py:116 ops/models/job.py:102 #: perms/serializers/user_permission.py:26 terminal/models/applet/applet.py:31 #: terminal/models/component/storage.py:57 #: terminal/models/component/storage.py:146 terminal/serializers/applet.py:29 @@ -599,7 +599,7 @@ msgstr "特別情報" #: accounts/serializers/automations/base.py:22 #: assets/models/automations/base.py:19 #: assets/serializers/automations/base.py:20 ops/models/base.py:17 -#: ops/models/job.py:103 ops/serializers/job.py:20 +#: ops/models/job.py:104 ops/serializers/job.py:20 #: terminal/templates/terminal/_msg_command_execute_alert.html:16 msgid "Assets" msgstr "資産" @@ -1065,7 +1065,7 @@ msgstr "SSHパブリックキー" #: assets/models/_user.py:27 assets/models/cmd_filter.py:40 #: assets/models/cmd_filter.py:88 assets/models/group.py:23 -#: common/db/models.py:37 ops/models/adhoc.py:27 ops/models/job.py:109 +#: common/db/models.py:37 ops/models/adhoc.py:27 ops/models/job.py:110 #: ops/models/playbook.py:26 rbac/models/role.py:37 settings/models.py:38 #: terminal/models/applet/applet.py:36 terminal/models/applet/applet.py:158 #: terminal/models/applet/host.py:111 terminal/models/component/endpoint.py:24 @@ -1078,7 +1078,7 @@ msgstr "コメント" #: assets/models/_user.py:28 assets/models/automations/base.py:113 #: assets/models/cmd_filter.py:41 assets/models/group.py:22 -#: common/db/models.py:35 ops/models/base.py:54 ops/models/job.py:185 +#: common/db/models.py:35 ops/models/base.py:54 ops/models/job.py:190 #: users/models/user.py:943 msgid "Date created" msgstr "作成された日付" @@ -1267,7 +1267,7 @@ msgid "Asset automation task" msgstr "アセットの自動化タスク" #: assets/models/automations/base.py:112 audits/models.py:177 -#: audits/serializers.py:49 ops/models/base.py:49 ops/models/job.py:178 +#: audits/serializers.py:49 ops/models/base.py:49 ops/models/job.py:183 #: terminal/models/applet/applet.py:157 terminal/models/applet/host.py:108 #: terminal/models/component/status.py:27 terminal/serializers/applet.py:18 #: terminal/serializers/applet_host.py:93 tickets/models/ticket/general.py:283 @@ -3279,7 +3279,7 @@ msgstr "VCS" msgid "Adhoc" msgstr "コマンド#コマンド#" -#: ops/const.py:39 ops/models/job.py:99 +#: ops/const.py:39 ops/models/job.py:100 msgid "Playbook" msgstr "Playbook" @@ -3340,17 +3340,17 @@ msgstr "定期的または定期的に設定を行う必要があります" msgid "Pattern" msgstr "パターン" -#: ops/models/adhoc.py:24 ops/models/job.py:94 +#: ops/models/adhoc.py:24 ops/models/job.py:95 msgid "Module" msgstr "モジュール" -#: ops/models/adhoc.py:25 ops/models/celery.py:58 ops/models/job.py:93 +#: ops/models/adhoc.py:25 ops/models/celery.py:58 ops/models/job.py:94 #: terminal/models/component/task.py:16 msgid "Args" msgstr "アルグ" #: ops/models/adhoc.py:26 ops/models/base.py:16 ops/models/base.py:53 -#: ops/models/job.py:102 ops/models/job.py:184 ops/models/playbook.py:25 +#: ops/models/job.py:103 ops/models/job.py:189 ops/models/playbook.py:25 #: terminal/models/session/sharing.py:23 msgid "Creator" msgstr "作成者" @@ -3367,12 +3367,12 @@ msgstr "最後の実行" msgid "Date last run" msgstr "最終実行日" -#: ops/models/base.py:51 ops/models/job.py:182 +#: ops/models/base.py:51 ops/models/job.py:187 #: xpack/plugins/cloud/models.py:170 msgid "Result" msgstr "結果" -#: ops/models/base.py:52 ops/models/job.py:183 +#: ops/models/base.py:52 ops/models/job.py:188 msgid "Summary" msgstr "概要" @@ -3412,47 +3412,47 @@ msgstr "発売日" msgid "Celery Task Execution" msgstr "Celery タスク実行" -#: ops/models/job.py:96 +#: ops/models/job.py:97 msgid "Chdir" msgstr "実行ディレクトリ" -#: ops/models/job.py:97 +#: ops/models/job.py:98 msgid "Timeout (Seconds)" msgstr "タイムアウト(秒)" -#: ops/models/job.py:104 +#: ops/models/job.py:105 msgid "Use Parameter Define" msgstr "パラメータ定義を使用する" -#: ops/models/job.py:105 +#: ops/models/job.py:106 msgid "Parameters define" msgstr "パラメータ定義" -#: ops/models/job.py:106 +#: ops/models/job.py:107 msgid "Runas" msgstr "ユーザーとして実行" -#: ops/models/job.py:108 +#: ops/models/job.py:109 msgid "Runas policy" msgstr "ユーザー ポリシー" -#: ops/models/job.py:170 +#: ops/models/job.py:171 msgid "Job" msgstr "ジョブ#ジョブ#" -#: ops/models/job.py:181 +#: ops/models/job.py:186 msgid "Parameters" msgstr "パラメータ" -#: ops/models/job.py:189 +#: ops/models/job.py:194 msgid "Material" msgstr "" -#: ops/models/job.py:191 +#: ops/models/job.py:196 msgid "Material Type" msgstr "" -#: ops/models/job.py:442 +#: ops/models/job.py:455 msgid "Job Execution" msgstr "ジョブ実行" @@ -3528,6 +3528,10 @@ msgstr "定期的なタスクの作成または更新" msgid "Periodic check service performance" msgstr "サービスのパフォーマンスを定期的に確認する" +#: ops/tasks.py:114 +msgid "Clean up unexpected jobs" +msgstr "例外ジョブのクリーンアップ" + #: ops/templates/ops/celery_task_log.html:4 msgid "Task log" msgstr "タスクログ" @@ -5987,19 +5991,19 @@ msgstr "" "チケットのタイトル: {} チケット申請者: {} チケットプロセッサ: {} チケットID: " "{}" -#: tickets/handlers/base.py:86 +#: tickets/handlers/base.py:85 msgid "Change field" msgstr "フィールドを変更" -#: tickets/handlers/base.py:86 +#: tickets/handlers/base.py:85 msgid "Before change" msgstr "変更前" -#: tickets/handlers/base.py:86 +#: tickets/handlers/base.py:85 msgid "After change" msgstr "変更後" -#: tickets/handlers/base.py:98 +#: tickets/handlers/base.py:97 msgid "{} {} the ticket" msgstr "{} {} チケット" @@ -6255,7 +6259,7 @@ msgstr "無効な承認アクション" msgid "This user is not authorized to approve this ticket" msgstr "このユーザーはこの作業指示を承認する権限がありません" -#: users/api/user.py:179 +#: users/api/user.py:182 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 89a9dbcc4..1c622bbe9 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-02-22 21:23+0800\n" +"POT-Creation-Date: 2023-02-23 16:29+0800\n" "PO-Revision-Date: 2021-05-20 10:54+0800\n" "Last-Translator: ibuler \n" "Language-Team: JumpServer team\n" @@ -248,7 +248,7 @@ msgstr "账号备份计划" #: accounts/models/automations/backup_account.py:83 #: assets/models/automations/base.py:114 audits/models.py:55 -#: ops/models/base.py:55 ops/models/celery.py:63 ops/models/job.py:186 +#: ops/models/base.py:55 ops/models/celery.py:63 ops/models/job.py:191 #: perms/models/asset_permission.py:72 terminal/models/applet/host.py:109 #: terminal/models/session/session.py:45 #: tickets/models/ticket/apply_application.py:30 @@ -370,7 +370,7 @@ msgstr "开始日期" #: accounts/models/automations/change_secret.py:74 #: assets/models/automations/base.py:115 ops/models/base.py:56 -#: ops/models/celery.py:64 ops/models/job.py:187 +#: ops/models/celery.py:64 ops/models/job.py:192 #: terminal/models/applet/host.py:110 msgid "Date finished" msgstr "结束日期" @@ -449,7 +449,7 @@ msgstr "账号验证" #: assets/serializers/platform.py:91 assets/serializers/platform.py:136 #: authentication/serializers/connect_token_secret.py:103 ops/mixin.py:21 #: ops/models/adhoc.py:21 ops/models/celery.py:15 ops/models/celery.py:57 -#: ops/models/job.py:90 ops/models/playbook.py:23 ops/serializers/job.py:19 +#: ops/models/job.py:91 ops/models/playbook.py:23 ops/serializers/job.py:19 #: orgs/models.py:69 perms/models/asset_permission.py:56 rbac/models/role.py:29 #: settings/models.py:33 settings/serializers/sms.py:6 #: terminal/models/applet/applet.py:27 terminal/models/component/endpoint.py:12 @@ -542,7 +542,7 @@ msgstr "类别" #: assets/models/cmd_filter.py:74 assets/models/platform.py:78 #: assets/serializers/asset/common.py:122 assets/serializers/platform.py:96 #: audits/serializers.py:48 -#: authentication/serializers/connect_token_secret.py:116 ops/models/job.py:101 +#: authentication/serializers/connect_token_secret.py:116 ops/models/job.py:102 #: perms/serializers/user_permission.py:26 terminal/models/applet/applet.py:31 #: terminal/models/component/storage.py:57 #: terminal/models/component/storage.py:146 terminal/serializers/applet.py:29 @@ -595,7 +595,7 @@ msgstr "特殊信息" #: accounts/serializers/automations/base.py:22 #: assets/models/automations/base.py:19 #: assets/serializers/automations/base.py:20 ops/models/base.py:17 -#: ops/models/job.py:103 ops/serializers/job.py:20 +#: ops/models/job.py:104 ops/serializers/job.py:20 #: terminal/templates/terminal/_msg_command_execute_alert.html:16 msgid "Assets" msgstr "资产" @@ -1057,7 +1057,7 @@ msgstr "SSH公钥" #: assets/models/_user.py:27 assets/models/cmd_filter.py:40 #: assets/models/cmd_filter.py:88 assets/models/group.py:23 -#: common/db/models.py:37 ops/models/adhoc.py:27 ops/models/job.py:109 +#: common/db/models.py:37 ops/models/adhoc.py:27 ops/models/job.py:110 #: ops/models/playbook.py:26 rbac/models/role.py:37 settings/models.py:38 #: terminal/models/applet/applet.py:36 terminal/models/applet/applet.py:158 #: terminal/models/applet/host.py:111 terminal/models/component/endpoint.py:24 @@ -1070,7 +1070,7 @@ msgstr "备注" #: assets/models/_user.py:28 assets/models/automations/base.py:113 #: assets/models/cmd_filter.py:41 assets/models/group.py:22 -#: common/db/models.py:35 ops/models/base.py:54 ops/models/job.py:185 +#: common/db/models.py:35 ops/models/base.py:54 ops/models/job.py:190 #: users/models/user.py:943 msgid "Date created" msgstr "创建日期" @@ -1259,7 +1259,7 @@ msgid "Asset automation task" msgstr "资产自动化任务" #: assets/models/automations/base.py:112 audits/models.py:177 -#: audits/serializers.py:49 ops/models/base.py:49 ops/models/job.py:178 +#: audits/serializers.py:49 ops/models/base.py:49 ops/models/job.py:183 #: terminal/models/applet/applet.py:157 terminal/models/applet/host.py:108 #: terminal/models/component/status.py:27 terminal/serializers/applet.py:18 #: terminal/serializers/applet_host.py:93 tickets/models/ticket/general.py:283 @@ -3244,7 +3244,7 @@ msgstr "VCS" msgid "Adhoc" msgstr "命令" -#: ops/const.py:39 ops/models/job.py:99 +#: ops/const.py:39 ops/models/job.py:100 msgid "Playbook" msgstr "Playbook" @@ -3305,17 +3305,17 @@ msgstr "需要周期或定期设置" msgid "Pattern" msgstr "模式" -#: ops/models/adhoc.py:24 ops/models/job.py:94 +#: ops/models/adhoc.py:24 ops/models/job.py:95 msgid "Module" msgstr "模块" -#: ops/models/adhoc.py:25 ops/models/celery.py:58 ops/models/job.py:93 +#: ops/models/adhoc.py:25 ops/models/celery.py:58 ops/models/job.py:94 #: terminal/models/component/task.py:16 msgid "Args" msgstr "参数" #: ops/models/adhoc.py:26 ops/models/base.py:16 ops/models/base.py:53 -#: ops/models/job.py:102 ops/models/job.py:184 ops/models/playbook.py:25 +#: ops/models/job.py:103 ops/models/job.py:189 ops/models/playbook.py:25 #: terminal/models/session/sharing.py:23 msgid "Creator" msgstr "创建者" @@ -3332,12 +3332,12 @@ msgstr "最后执行" msgid "Date last run" msgstr "最后运行日期" -#: ops/models/base.py:51 ops/models/job.py:182 +#: ops/models/base.py:51 ops/models/job.py:187 #: xpack/plugins/cloud/models.py:170 msgid "Result" msgstr "结果" -#: ops/models/base.py:52 ops/models/job.py:183 +#: ops/models/base.py:52 ops/models/job.py:188 msgid "Summary" msgstr "汇总" @@ -3377,47 +3377,47 @@ msgstr "发布日期" msgid "Celery Task Execution" msgstr "Celery 任务执行" -#: ops/models/job.py:96 +#: ops/models/job.py:97 msgid "Chdir" msgstr "运行目录" -#: ops/models/job.py:97 +#: ops/models/job.py:98 msgid "Timeout (Seconds)" msgstr "超时时间(秒)" -#: ops/models/job.py:104 +#: ops/models/job.py:105 msgid "Use Parameter Define" msgstr "使用参数定义" -#: ops/models/job.py:105 +#: ops/models/job.py:106 msgid "Parameters define" msgstr "参数定义" -#: ops/models/job.py:106 +#: ops/models/job.py:107 msgid "Runas" msgstr "运行用户" -#: ops/models/job.py:108 +#: ops/models/job.py:109 msgid "Runas policy" msgstr "用户策略" -#: ops/models/job.py:170 +#: ops/models/job.py:171 msgid "Job" msgstr "作业" -#: ops/models/job.py:181 +#: ops/models/job.py:186 msgid "Parameters" msgstr "参数" -#: ops/models/job.py:189 +#: ops/models/job.py:194 msgid "Material" msgstr "" -#: ops/models/job.py:191 +#: ops/models/job.py:196 msgid "Material Type" msgstr "" -#: ops/models/job.py:442 +#: ops/models/job.py:455 msgid "Job Execution" msgstr "作业执行" @@ -3493,6 +3493,10 @@ msgstr "创建或更新周期任务" msgid "Periodic check service performance" msgstr "周期检测服务性能" +#: ops/tasks.py:114 +msgid "Clean up unexpected jobs" +msgstr "清理异常作业" + #: ops/templates/ops/celery_task_log.html:4 msgid "Task log" msgstr "任务列表" @@ -5909,19 +5913,19 @@ msgid "" msgstr "" "通过工单创建, 工单标题: {}, 工单申请人: {}, 工单处理人: {}, 工单 ID: {}" -#: tickets/handlers/base.py:86 +#: tickets/handlers/base.py:85 msgid "Change field" msgstr "变更字段" -#: tickets/handlers/base.py:86 +#: tickets/handlers/base.py:85 msgid "Before change" msgstr "变更前" -#: tickets/handlers/base.py:86 +#: tickets/handlers/base.py:85 msgid "After change" msgstr "变更后" -#: tickets/handlers/base.py:98 +#: tickets/handlers/base.py:97 msgid "{} {} the ticket" msgstr "{} {} 工单" @@ -6175,7 +6179,7 @@ msgstr "无效的审批动作" msgid "This user is not authorized to approve this ticket" msgstr "此用户无权审批此工单" -#: users/api/user.py:179 +#: users/api/user.py:182 msgid "Could not reset self otp, use profile reset instead" msgstr "不能在该页面重置 MFA 多因子认证, 请去个人信息页面重置" diff --git a/apps/ops/models/job.py b/apps/ops/models/job.py index 4cb297191..ed936ddba 100644 --- a/apps/ops/models/job.py +++ b/apps/ops/models/job.py @@ -3,6 +3,7 @@ import logging import os import uuid from collections import defaultdict +from datetime import timedelta from celery import current_task from django.conf import settings @@ -172,6 +173,10 @@ class Job(JMSOrgBaseModel, PeriodTaskModelMixin): ordering = ['date_created'] +zombie_task_exception = Exception( + 'This task has been marked as a zombie task because it has not updated its status for too long') + + class JobExecution(JMSOrgBaseModel): id = models.UUIDField(default=uuid.uuid4, primary_key=True) task_id = models.UUIDField(null=True) @@ -190,6 +195,14 @@ class JobExecution(JMSOrgBaseModel): job_type = models.CharField(max_length=128, choices=Types.choices, default=Types.adhoc, verbose_name=_("Material Type")) + # clean up zombie execution + + @classmethod + def clean_unexpected_execution(cls): + for execution in cls.objects.filter(status__in=[JobStatus.running]).all(): + if execution.date_created < (timezone.now() - timedelta(hours=3)): + execution.set_error(zombie_task_exception) + @property def current_job(self): if self.job.version != self.job_version: diff --git a/apps/ops/tasks.py b/apps/ops/tasks.py index aff569ba7..833e20ea0 100644 --- a/apps/ops/tasks.py +++ b/apps/ops/tasks.py @@ -5,7 +5,7 @@ from celery.exceptions import SoftTimeLimitExceeded from django.utils.translation import ugettext_lazy as _ from common.utils import get_logger, get_object_or_none -from orgs.utils import tmp_to_org +from orgs.utils import tmp_to_org, tmp_to_root_org from .celery.decorator import ( register_as_period_task, after_app_ready_start ) @@ -109,3 +109,10 @@ def create_or_update_registered_periodic_tasks(): @register_as_period_task(interval=3600) def check_server_performance_period(): ServerPerformanceCheckUtil().check_and_publish() + + +@shared_task(verbose_name=_("Clean up unexpected jobs")) +@register_as_period_task(interval=3600) +def clean_up_unexpected_jobs(): + with tmp_to_root_org(): + JobExecution.clean_unexpected_execution() From 1a9cd2dee235cf81c23239a0ed9ca59219e585c6 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 23 Feb 2023 17:44:38 +0800 Subject: [PATCH 12/21] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E8=B5=84?= =?UTF-8?q?=E4=BA=A7=E6=89=B9=E9=87=8F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/serializers/asset/common.py | 3 +-- apps/perms/api/user_permission/assets.py | 3 +-- apps/perms/serializers/user_permission.py | 12 +++++++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/apps/assets/serializers/asset/common.py b/apps/assets/serializers/asset/common.py index c4f2a5da7..01a8bc7b8 100644 --- a/apps/assets/serializers/asset/common.py +++ b/apps/assets/serializers/asset/common.py @@ -11,7 +11,6 @@ from accounts.serializers import AccountSerializerCreateValidateMixin from accounts.serializers import AuthValidateMixin from common.serializers import WritableNestedModelSerializer, SecretReadableMixin, CommonModelSerializer from common.serializers.fields import LabeledChoiceField -from common.utils import lazyproperty from orgs.mixins.serializers import BulkOrgResourceModelSerializer from ...const import Category, AllTypes from ...models import Asset, Node, Platform, Label, Protocol @@ -205,7 +204,7 @@ class AssetSerializer(BulkOrgResourceModelSerializer, WritableNestedModelSeriali nodes_to_set.append(node) instance.nodes.set(nodes_to_set) - @lazyproperty + @property def _initial_data_platform(self): if self.instance: return self.instance.platform diff --git a/apps/perms/api/user_permission/assets.py b/apps/perms/api/user_permission/assets.py index 98339fde3..0daa23791 100644 --- a/apps/perms/api/user_permission/assets.py +++ b/apps/perms/api/user_permission/assets.py @@ -29,13 +29,12 @@ class BaseUserPermedAssetsApi(SelfOrPKUserMixin, ListAPIView): ordering_fields = ("name", "address") filterset_class = AssetFilterSet serializer_class = serializers.AssetPermedSerializer - only_fields = serializers.AssetPermedSerializer.Meta.only_fields def get_queryset(self): if getattr(self, 'swagger_fake_view', False): return Asset.objects.none() assets = self.get_assets() - assets = assets.prefetch_related('platform').only(*self.only_fields) + assets = self.serializer_class.setup_eager_loading(assets) return assets @abc.abstractmethod diff --git a/apps/perms/serializers/user_permission.py b/apps/perms/serializers/user_permission.py index 27fde71d1..34143d936 100644 --- a/apps/perms/serializers/user_permission.py +++ b/apps/perms/serializers/user_permission.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # +from django.db.models import F from django.utils.translation import ugettext_lazy as _ from rest_framework import serializers @@ -32,9 +33,18 @@ class AssetPermedSerializer(OrgResourceModelSerializerMixin): "id", "name", "address", 'domain', 'platform', "comment", "org_id", "is_active", ] - fields = only_fields + ['protocols', 'category', 'type', 'spec_info'] + ['org_name'] + fields = only_fields + ['protocols', 'category', 'type'] + ['org_name'] read_only_fields = fields + @classmethod + def setup_eager_loading(cls, queryset): + """ Perform necessary eager loading of data. """ + queryset = queryset.prefetch_related('domain', 'nodes', 'labels') \ + .prefetch_related('platform', 'protocols') \ + .annotate(category=F("platform__category")) \ + .annotate(type=F("platform__type")) + return queryset + class NodePermedSerializer(serializers.ModelSerializer): class Meta: From 9f8900041d280bcc60c5fc8b13a39d4c74f74590 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 23 Feb 2023 18:08:56 +0800 Subject: [PATCH 13/21] per: gather account perm (#9723) Co-authored-by: feng <1304903146@qq.com> Co-authored-by: feng626 <57284900+feng626@users.noreply.github.com> --- .../0008_alter_gatheredaccount_options.py | 17 ++ .../models/automations/gather_account.py | 6 +- apps/locale/ja/LC_MESSAGES/django.mo | 4 +- apps/locale/ja/LC_MESSAGES/django.po | 178 +++++++++--------- apps/locale/zh/LC_MESSAGES/django.mo | 4 +- apps/locale/zh/LC_MESSAGES/django.po | 166 ++++++++-------- apps/rbac/tree.py | 12 +- 7 files changed, 205 insertions(+), 182 deletions(-) create mode 100644 apps/accounts/migrations/0008_alter_gatheredaccount_options.py diff --git a/apps/accounts/migrations/0008_alter_gatheredaccount_options.py b/apps/accounts/migrations/0008_alter_gatheredaccount_options.py new file mode 100644 index 000000000..d2600e700 --- /dev/null +++ b/apps/accounts/migrations/0008_alter_gatheredaccount_options.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.16 on 2023-02-23 09:59 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0007_alter_account_options'), + ] + + operations = [ + migrations.AlterModelOptions( + name='gatheredaccount', + options={'ordering': ['asset'], 'verbose_name': 'Gather account automation'}, + ), + ] diff --git a/apps/accounts/models/automations/gather_account.py b/apps/accounts/models/automations/gather_account.py index ced7995c7..01f903141 100644 --- a/apps/accounts/models/automations/gather_account.py +++ b/apps/accounts/models/automations/gather_account.py @@ -1,10 +1,8 @@ -from django.utils.translation import ugettext_lazy as _ - from django.db import models from django.utils.translation import ugettext_lazy as _ -from orgs.mixins.models import JMSOrgBaseModel from accounts.const import AutomationTypes +from orgs.mixins.models import JMSOrgBaseModel from .base import AccountBaseAutomation __all__ = ['GatherAccountsAutomation', 'GatheredAccount'] @@ -22,7 +20,7 @@ class GatheredAccount(JMSOrgBaseModel): return self.asset.address class Meta: - verbose_name = _('Gather account') + verbose_name = _('Gather account automation') unique_together = [ ('username', 'asset'), ] diff --git a/apps/locale/ja/LC_MESSAGES/django.mo b/apps/locale/ja/LC_MESSAGES/django.mo index 781aa1a90..4385e4c98 100644 --- a/apps/locale/ja/LC_MESSAGES/django.mo +++ b/apps/locale/ja/LC_MESSAGES/django.mo @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:af57d16430705feb02ebbb99fc3a2f5fc3bab69209f558aa4d69b1e8055a6f5f -size 136036 +oid sha256:fa23550c6fd74b0f0e586990eb5eb54f2717db9f2e6b0513151d205a34fa2383 +size 136199 diff --git a/apps/locale/ja/LC_MESSAGES/django.po b/apps/locale/ja/LC_MESSAGES/django.po index ac6f12e6a..4de6c1775 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-02-23 16:29+0800\n" +"POT-Creation-Date: 2023-02-23 17:59+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -70,7 +70,7 @@ msgstr "ローカル" msgid "Collected" msgstr "" -#: accounts/const/automation.py:22 rbac/tree.py:51 +#: accounts/const/automation.py:22 rbac/tree.py:50 msgid "Push account" msgstr "アカウントプッシュ" @@ -159,7 +159,7 @@ msgid "Only create" msgstr "作成のみ" #: accounts/models/account.py:47 -#: accounts/models/automations/gather_account.py:16 +#: accounts/models/automations/gather_account.py:14 #: accounts/serializers/account/account.py:95 #: accounts/serializers/account/gathered_account.py:10 #: accounts/serializers/automations/change_secret.py:111 @@ -172,7 +172,7 @@ msgstr "作成のみ" #: perms/models/asset_permission.py:64 perms/serializers/permission.py:27 #: terminal/backends/command/models.py:20 terminal/models/session/session.py:32 #: terminal/notifications.py:95 terminal/serializers/command.py:17 -#: tickets/models/ticket/apply_asset.py:16 xpack/plugins/cloud/models.py:220 +#: tickets/models/ticket/apply_asset.py:16 xpack/plugins/cloud/models.py:212 msgid "Asset" msgstr "資産" @@ -276,7 +276,7 @@ msgid "Trigger mode" msgstr "トリガーモード" #: accounts/models/automations/backup_account.py:97 audits/models.py:172 -#: terminal/models/session/sharing.py:107 xpack/plugins/cloud/models.py:176 +#: terminal/models/session/sharing.py:107 xpack/plugins/cloud/models.py:168 msgid "Reason" msgstr "理由" @@ -385,15 +385,15 @@ msgstr "間違い" msgid "Change secret record" msgstr "パスワード レコードの変更" -#: accounts/models/automations/gather_account.py:14 +#: accounts/models/automations/gather_account.py:12 msgid "Present" msgstr "存在する" -#: accounts/models/automations/gather_account.py:15 +#: accounts/models/automations/gather_account.py:13 msgid "Date last login" msgstr "最終ログイン日" -#: accounts/models/automations/gather_account.py:17 +#: accounts/models/automations/gather_account.py:15 #: accounts/models/automations/push_account.py:13 accounts/models/base.py:34 #: acls/serializers/base.py:18 acls/serializers/base.py:49 #: assets/models/_user.py:23 audits/models.py:157 authentication/forms.py:25 @@ -406,15 +406,15 @@ msgstr "最終ログイン日" msgid "Username" msgstr "ユーザー名" -#: accounts/models/automations/gather_account.py:18 +#: accounts/models/automations/gather_account.py:16 msgid "Address last login" msgstr "最終ログインアドレス" -#: accounts/models/automations/gather_account.py:25 rbac/tree.py:50 -msgid "Gather account" -msgstr "アカウントを集める" +#: accounts/models/automations/gather_account.py:23 +msgid "Gather account automation" +msgstr "自動収集アカウント" -#: accounts/models/automations/gather_account.py:41 +#: accounts/models/automations/gather_account.py:39 #: accounts/tasks/gather_accounts.py:29 msgid "Gather asset accounts" msgstr "アカウントのコレクション" @@ -1072,7 +1072,7 @@ msgstr "SSHパブリックキー" #: terminal/models/component/endpoint.py:100 #: terminal/models/session/session.py:47 tickets/models/comment.py:32 #: tickets/models/ticket/general.py:297 users/models/user.py:756 -#: xpack/plugins/cloud/models.py:35 xpack/plugins/cloud/models.py:119 +#: xpack/plugins/cloud/models.py:35 xpack/plugins/cloud/models.py:111 msgid "Comment" msgstr "コメント" @@ -1183,7 +1183,7 @@ msgstr "アドレス" #: assets/models/asset/common.py:104 assets/models/platform.py:112 #: authentication/serializers/connect_token_secret.py:108 #: perms/serializers/user_permission.py:23 -#: xpack/plugins/cloud/serializers/account_attrs.py:179 +#: xpack/plugins/cloud/serializers/account_attrs.py:187 msgid "Platform" msgstr "プラットフォーム" @@ -1254,7 +1254,7 @@ msgid "Submit selector" msgstr "ボタンセレクターを確認する" #: assets/models/automations/base.py:17 assets/models/cmd_filter.py:38 -#: assets/serializers/asset/common.py:289 rbac/tree.py:36 +#: assets/serializers/asset/common.py:289 rbac/tree.py:35 msgid "Accounts" msgstr "アカウント" @@ -1272,8 +1272,8 @@ msgstr "アセットの自動化タスク" #: terminal/models/component/status.py:27 terminal/serializers/applet.py:18 #: terminal/serializers/applet_host.py:93 tickets/models/ticket/general.py:283 #: tickets/serializers/super_ticket.py:13 -#: tickets/serializers/ticket/ticket.py:20 xpack/plugins/cloud/models.py:172 -#: xpack/plugins/cloud/models.py:224 +#: tickets/serializers/ticket/ticket.py:20 xpack/plugins/cloud/models.py:164 +#: xpack/plugins/cloud/models.py:216 msgid "Status" msgstr "ステータス" @@ -1492,8 +1492,7 @@ msgstr "自動充填" #: assets/serializers/asset/common.py:124 assets/serializers/platform.py:99 #: authentication/serializers/connect_token_secret.py:28 #: authentication/serializers/connect_token_secret.py:66 -#: perms/serializers/user_permission.py:24 xpack/plugins/cloud/models.py:107 -#: xpack/plugins/cloud/serializers/task.py:38 +#: perms/serializers/user_permission.py:24 xpack/plugins/cloud/models.py:99 msgid "Protocols" msgstr "プロトコル" @@ -1520,6 +1519,8 @@ msgstr "自動情報" #: assets/serializers/asset/database.py:25 common/serializers/fields.py:100 #: tickets/serializers/ticket/common.py:58 #: xpack/plugins/cloud/serializers/account_attrs.py:56 +#: xpack/plugins/cloud/serializers/account_attrs.py:79 +#: xpack/plugins/cloud/serializers/account_attrs.py:143 msgid "This field is required." msgstr "このフィールドは必須です。" @@ -3239,7 +3240,7 @@ msgstr "タスク実行パラメータエラー" msgid "Unsupported file content" msgstr "サポートされていないファイルの内容" -#: ops/apps.py:9 ops/notifications.py:16 rbac/tree.py:56 +#: ops/apps.py:9 ops/notifications.py:16 rbac/tree.py:55 msgid "App ops" msgstr "アプリ操作" @@ -3859,59 +3860,63 @@ msgstr "ロール表示" msgid "Has bound this role" msgstr "この役割をバインドしました" -#: rbac/tree.py:18 rbac/tree.py:19 +#: rbac/tree.py:17 rbac/tree.py:18 msgid "All permissions" msgstr "すべての権限" -#: rbac/tree.py:25 +#: rbac/tree.py:24 msgid "Console view" msgstr "コンソールビュー" -#: rbac/tree.py:26 +#: rbac/tree.py:25 msgid "Workbench view" msgstr "ワークスペースビュー" -#: rbac/tree.py:27 +#: rbac/tree.py:26 msgid "Audit view" msgstr "監査ビュー" -#: rbac/tree.py:28 settings/models.py:159 +#: rbac/tree.py:27 settings/models.py:159 msgid "System setting" msgstr "システム設定" -#: rbac/tree.py:29 +#: rbac/tree.py:28 msgid "Other" msgstr "その他" -#: rbac/tree.py:38 +#: rbac/tree.py:37 msgid "Session audits" msgstr "セッション監査" -#: rbac/tree.py:48 +#: rbac/tree.py:47 msgid "Cloud import" msgstr "クラウドインポート" -#: rbac/tree.py:49 +#: rbac/tree.py:48 msgid "Backup account" msgstr "バックアップアカウント" -#: rbac/tree.py:52 +#: rbac/tree.py:49 +msgid "Gather account" +msgstr "アカウントを集める" + +#: rbac/tree.py:51 msgid "Asset change auth" msgstr "資産の改ざん" -#: rbac/tree.py:53 +#: rbac/tree.py:52 msgid "Terminal setting" msgstr "ターミナル設定" -#: rbac/tree.py:54 +#: rbac/tree.py:53 msgid "Task Center" msgstr "タスクセンター" -#: rbac/tree.py:55 +#: rbac/tree.py:54 msgid "My assets" msgstr "私の資産" -#: rbac/tree.py:57 terminal/models/applet/applet.py:43 +#: rbac/tree.py:56 terminal/models/applet/applet.py:43 #: terminal/models/applet/applet.py:154 terminal/models/applet/host.py:28 #: terminal/serializers/applet.py:15 msgid "Applet" @@ -4412,7 +4417,7 @@ msgid "SSO auth key TTL" msgstr "Token有効期間" #: settings/serializers/auth/sso.py:17 -#: xpack/plugins/cloud/serializers/account_attrs.py:176 +#: xpack/plugins/cloud/serializers/account_attrs.py:184 msgid "Unit: second" msgstr "単位: 秒" @@ -5825,7 +5830,7 @@ msgstr "アクセスキー" msgid "Access key secret" msgstr "アクセスキーシークレット" -#: terminal/serializers/storage.py:65 xpack/plugins/cloud/models.py:217 +#: terminal/serializers/storage.py:65 xpack/plugins/cloud/models.py:209 msgid "Region" msgstr "リージョン" @@ -6956,59 +6961,47 @@ msgstr "リージョン" msgid "Hostname strategy" msgstr "ホスト名戦略" -#: xpack/plugins/cloud/models.py:100 -#, fuzzy -#| msgid "Only admin users" -msgid "Unix admin user" -msgstr "管理者のみ" - -#: xpack/plugins/cloud/models.py:104 -#, fuzzy -#| msgid "Only admin users" -msgid "Windows admin user" -msgstr "管理者のみ" - -#: xpack/plugins/cloud/models.py:110 xpack/plugins/cloud/serializers/task.py:41 +#: xpack/plugins/cloud/models.py:102 xpack/plugins/cloud/serializers/task.py:40 msgid "IP network segment group" msgstr "IPネットワークセグメントグループ" -#: xpack/plugins/cloud/models.py:113 xpack/plugins/cloud/serializers/task.py:46 +#: xpack/plugins/cloud/models.py:105 xpack/plugins/cloud/serializers/task.py:45 msgid "Sync IP type" msgstr "同期IPタイプ" -#: xpack/plugins/cloud/models.py:116 xpack/plugins/cloud/serializers/task.py:64 +#: xpack/plugins/cloud/models.py:108 xpack/plugins/cloud/serializers/task.py:62 msgid "Always update" msgstr "常に更新" -#: xpack/plugins/cloud/models.py:122 +#: xpack/plugins/cloud/models.py:114 msgid "Date last sync" msgstr "最終同期日" -#: xpack/plugins/cloud/models.py:127 xpack/plugins/cloud/models.py:168 +#: xpack/plugins/cloud/models.py:119 xpack/plugins/cloud/models.py:160 msgid "Sync instance task" msgstr "インスタンスの同期タスク" -#: xpack/plugins/cloud/models.py:179 xpack/plugins/cloud/models.py:227 +#: xpack/plugins/cloud/models.py:171 xpack/plugins/cloud/models.py:219 msgid "Date sync" msgstr "日付の同期" -#: xpack/plugins/cloud/models.py:183 +#: xpack/plugins/cloud/models.py:175 msgid "Sync instance task execution" msgstr "インスタンスタスクの同期実行" -#: xpack/plugins/cloud/models.py:207 +#: xpack/plugins/cloud/models.py:199 msgid "Sync task" msgstr "同期タスク" -#: xpack/plugins/cloud/models.py:211 +#: xpack/plugins/cloud/models.py:203 msgid "Sync instance task history" msgstr "インスタンスタスク履歴の同期" -#: xpack/plugins/cloud/models.py:214 +#: xpack/plugins/cloud/models.py:206 msgid "Instance" msgstr "インスタンス" -#: xpack/plugins/cloud/models.py:231 +#: xpack/plugins/cloud/models.py:223 msgid "Sync instance detail" msgstr "同期インスタンスの詳細" @@ -7222,52 +7215,52 @@ msgstr "テナントID" msgid "Subscription ID" msgstr "サブスクリプションID" -#: xpack/plugins/cloud/serializers/account_attrs.py:95 -#: xpack/plugins/cloud/serializers/account_attrs.py:100 -#: xpack/plugins/cloud/serializers/account_attrs.py:116 -#: xpack/plugins/cloud/serializers/account_attrs.py:141 +#: xpack/plugins/cloud/serializers/account_attrs.py:98 +#: xpack/plugins/cloud/serializers/account_attrs.py:103 +#: xpack/plugins/cloud/serializers/account_attrs.py:119 +#: xpack/plugins/cloud/serializers/account_attrs.py:149 msgid "API Endpoint" msgstr "APIエンドポイント" -#: xpack/plugins/cloud/serializers/account_attrs.py:106 +#: xpack/plugins/cloud/serializers/account_attrs.py:109 msgid "Auth url" msgstr "認証アドレス" -#: xpack/plugins/cloud/serializers/account_attrs.py:107 +#: xpack/plugins/cloud/serializers/account_attrs.py:110 msgid "eg: http://openstack.example.com:5000/v3" msgstr "例えば: http://openstack.example.com:5000/v3" -#: xpack/plugins/cloud/serializers/account_attrs.py:110 +#: xpack/plugins/cloud/serializers/account_attrs.py:113 msgid "User domain" msgstr "ユーザードメイン" -#: xpack/plugins/cloud/serializers/account_attrs.py:117 +#: xpack/plugins/cloud/serializers/account_attrs.py:120 msgid "Cert File" msgstr "証明書ファイル" -#: xpack/plugins/cloud/serializers/account_attrs.py:118 +#: xpack/plugins/cloud/serializers/account_attrs.py:121 msgid "Key File" msgstr "キーファイル" -#: xpack/plugins/cloud/serializers/account_attrs.py:134 +#: xpack/plugins/cloud/serializers/account_attrs.py:137 msgid "Service account key" msgstr "サービスアカウントキー" -#: xpack/plugins/cloud/serializers/account_attrs.py:135 +#: xpack/plugins/cloud/serializers/account_attrs.py:138 msgid "The file is in JSON format" msgstr "ファイルはJSON形式です。" -#: xpack/plugins/cloud/serializers/account_attrs.py:148 +#: xpack/plugins/cloud/serializers/account_attrs.py:156 msgid "IP address invalid `{}`, {}" msgstr "IPアドレスが無効: '{}', {}" -#: xpack/plugins/cloud/serializers/account_attrs.py:154 +#: xpack/plugins/cloud/serializers/account_attrs.py:162 msgid "" "Format for comma-delimited string,Such as: 192.168.1.0/24, " "10.0.0.0-10.0.0.255" msgstr "形式はコンマ区切りの文字列です,例:192.168.1.0/24,10.0.0.0-10.0.0.255" -#: xpack/plugins/cloud/serializers/account_attrs.py:158 +#: xpack/plugins/cloud/serializers/account_attrs.py:166 msgid "" "The port is used to detect the validity of the IP address. When the " "synchronization task is executed, only the valid IP address will be " @@ -7277,19 +7270,19 @@ msgstr "" "実行されると、有効な IP アドレスのみが同期されます。
ポートが0の場合、す" "べてのIPアドレスが有効です。" -#: xpack/plugins/cloud/serializers/account_attrs.py:166 +#: xpack/plugins/cloud/serializers/account_attrs.py:174 msgid "Hostname prefix" msgstr "ホスト名プレフィックス" -#: xpack/plugins/cloud/serializers/account_attrs.py:169 +#: xpack/plugins/cloud/serializers/account_attrs.py:177 msgid "IP segment" msgstr "IP セグメント" -#: xpack/plugins/cloud/serializers/account_attrs.py:173 +#: xpack/plugins/cloud/serializers/account_attrs.py:181 msgid "Test port" msgstr "テストポート" -#: xpack/plugins/cloud/serializers/account_attrs.py:176 +#: xpack/plugins/cloud/serializers/account_attrs.py:184 msgid "Test timeout" msgstr "テストタイムアウト" @@ -7315,11 +7308,13 @@ msgstr "実行回数" msgid "Instance count" msgstr "インスタンス数" -#: xpack/plugins/cloud/serializers/task.py:63 -#, fuzzy -#| msgid "Only admin users" -msgid "Linux admin user" -msgstr "管理者のみ" +#: xpack/plugins/cloud/tasks.py:27 +msgid "Run sync instance task" +msgstr "同期インスタンス タスクを実行する" + +#: xpack/plugins/cloud/tasks.py:41 +msgid "Period clean sync instance task execution" +msgstr "同期インスタンス タスクの実行記録を定期的にクリアする" #: xpack/plugins/cloud/utils.py:69 msgid "Account unavailable" @@ -7389,11 +7384,20 @@ msgstr "究極のエディション" msgid "Community edition" msgstr "コミュニティ版" -#~ msgid "Run sync instance task" -#~ msgstr "同期インスタンス タスクを実行する" +#, fuzzy +#~| msgid "Only admin users" +#~ msgid "Unix admin user" +#~ msgstr "管理者のみ" -#~ msgid "Period clean sync instance task execution" -#~ msgstr "同期インスタンス タスクの実行記録を定期的にクリアする" +#, fuzzy +#~| msgid "Only admin users" +#~ msgid "Windows admin user" +#~ msgstr "管理者のみ" + +#, fuzzy +#~| msgid "Only admin users" +#~ msgid "Linux admin user" +#~ msgstr "管理者のみ" #~ msgid "Can push account to asset" #~ msgstr "アカウントをアセットにプッシュできます" diff --git a/apps/locale/zh/LC_MESSAGES/django.mo b/apps/locale/zh/LC_MESSAGES/django.mo index 7315fa90d..45bd3cbec 100644 --- a/apps/locale/zh/LC_MESSAGES/django.mo +++ b/apps/locale/zh/LC_MESSAGES/django.mo @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e68b83ab7aac5be2b88ed9c64a626b41ebfc035ed733a206e2c0d69fcf21337b -size 111773 +oid sha256:a1627f904e2932024a40fe6548e9be4a1d5d4890b7915843b91f6e83b04cc77d +size 111903 diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index 1c622bbe9..854c7e0d5 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-02-23 16:29+0800\n" +"POT-Creation-Date: 2023-02-23 17:59+0800\n" "PO-Revision-Date: 2021-05-20 10:54+0800\n" "Last-Translator: ibuler \n" "Language-Team: JumpServer team\n" @@ -69,7 +69,7 @@ msgstr "数据库" msgid "Collected" msgstr "收集" -#: accounts/const/automation.py:22 rbac/tree.py:51 +#: accounts/const/automation.py:22 rbac/tree.py:50 msgid "Push account" msgstr "账号推送" @@ -158,7 +158,7 @@ msgid "Only create" msgstr "仅创建" #: accounts/models/account.py:47 -#: accounts/models/automations/gather_account.py:16 +#: accounts/models/automations/gather_account.py:14 #: accounts/serializers/account/account.py:95 #: accounts/serializers/account/gathered_account.py:10 #: accounts/serializers/automations/change_secret.py:111 @@ -171,7 +171,7 @@ msgstr "仅创建" #: perms/models/asset_permission.py:64 perms/serializers/permission.py:27 #: terminal/backends/command/models.py:20 terminal/models/session/session.py:32 #: terminal/notifications.py:95 terminal/serializers/command.py:17 -#: tickets/models/ticket/apply_asset.py:16 xpack/plugins/cloud/models.py:220 +#: tickets/models/ticket/apply_asset.py:16 xpack/plugins/cloud/models.py:212 msgid "Asset" msgstr "资产" @@ -275,7 +275,7 @@ msgid "Trigger mode" msgstr "触发模式" #: accounts/models/automations/backup_account.py:97 audits/models.py:172 -#: terminal/models/session/sharing.py:107 xpack/plugins/cloud/models.py:176 +#: terminal/models/session/sharing.py:107 xpack/plugins/cloud/models.py:168 msgid "Reason" msgstr "原因" @@ -384,15 +384,15 @@ msgstr "错误" msgid "Change secret record" msgstr "改密记录" -#: accounts/models/automations/gather_account.py:14 +#: accounts/models/automations/gather_account.py:12 msgid "Present" msgstr "存在" -#: accounts/models/automations/gather_account.py:15 +#: accounts/models/automations/gather_account.py:13 msgid "Date last login" msgstr "最后登录日期" -#: accounts/models/automations/gather_account.py:17 +#: accounts/models/automations/gather_account.py:15 #: accounts/models/automations/push_account.py:13 accounts/models/base.py:34 #: acls/serializers/base.py:18 acls/serializers/base.py:49 #: assets/models/_user.py:23 audits/models.py:157 authentication/forms.py:25 @@ -405,15 +405,15 @@ msgstr "最后登录日期" msgid "Username" msgstr "用户名" -#: accounts/models/automations/gather_account.py:18 +#: accounts/models/automations/gather_account.py:16 msgid "Address last login" msgstr "最后登录地址" -#: accounts/models/automations/gather_account.py:25 rbac/tree.py:50 -msgid "Gather account" -msgstr "收集账号" +#: accounts/models/automations/gather_account.py:23 +msgid "Gather account automation" +msgstr "自动化收集账号" -#: accounts/models/automations/gather_account.py:41 +#: accounts/models/automations/gather_account.py:39 #: accounts/tasks/gather_accounts.py:29 msgid "Gather asset accounts" msgstr "收集账号" @@ -1064,7 +1064,7 @@ msgstr "SSH公钥" #: terminal/models/component/endpoint.py:100 #: terminal/models/session/session.py:47 tickets/models/comment.py:32 #: tickets/models/ticket/general.py:297 users/models/user.py:756 -#: xpack/plugins/cloud/models.py:35 xpack/plugins/cloud/models.py:119 +#: xpack/plugins/cloud/models.py:35 xpack/plugins/cloud/models.py:111 msgid "Comment" msgstr "备注" @@ -1175,7 +1175,7 @@ msgstr "地址" #: assets/models/asset/common.py:104 assets/models/platform.py:112 #: authentication/serializers/connect_token_secret.py:108 #: perms/serializers/user_permission.py:23 -#: xpack/plugins/cloud/serializers/account_attrs.py:179 +#: xpack/plugins/cloud/serializers/account_attrs.py:187 msgid "Platform" msgstr "系统平台" @@ -1246,7 +1246,7 @@ msgid "Submit selector" msgstr "确认按钮选择器" #: assets/models/automations/base.py:17 assets/models/cmd_filter.py:38 -#: assets/serializers/asset/common.py:289 rbac/tree.py:36 +#: assets/serializers/asset/common.py:289 rbac/tree.py:35 msgid "Accounts" msgstr "账号管理" @@ -1264,8 +1264,8 @@ msgstr "资产自动化任务" #: terminal/models/component/status.py:27 terminal/serializers/applet.py:18 #: terminal/serializers/applet_host.py:93 tickets/models/ticket/general.py:283 #: tickets/serializers/super_ticket.py:13 -#: tickets/serializers/ticket/ticket.py:20 xpack/plugins/cloud/models.py:172 -#: xpack/plugins/cloud/models.py:224 +#: tickets/serializers/ticket/ticket.py:20 xpack/plugins/cloud/models.py:164 +#: xpack/plugins/cloud/models.py:216 msgid "Status" msgstr "状态" @@ -1484,8 +1484,7 @@ msgstr "自动代填" #: assets/serializers/asset/common.py:124 assets/serializers/platform.py:99 #: authentication/serializers/connect_token_secret.py:28 #: authentication/serializers/connect_token_secret.py:66 -#: perms/serializers/user_permission.py:24 xpack/plugins/cloud/models.py:107 -#: xpack/plugins/cloud/serializers/task.py:38 +#: perms/serializers/user_permission.py:24 xpack/plugins/cloud/models.py:99 msgid "Protocols" msgstr "协议组" @@ -1512,6 +1511,8 @@ msgstr "自动化信息" #: assets/serializers/asset/database.py:25 common/serializers/fields.py:100 #: tickets/serializers/ticket/common.py:58 #: xpack/plugins/cloud/serializers/account_attrs.py:56 +#: xpack/plugins/cloud/serializers/account_attrs.py:79 +#: xpack/plugins/cloud/serializers/account_attrs.py:143 msgid "This field is required." msgstr "该字段是必填项。" @@ -3204,7 +3205,7 @@ msgstr "任务 {} 执行参数错误" msgid "Unsupported file content" msgstr "不支持的文件内容" -#: ops/apps.py:9 ops/notifications.py:16 rbac/tree.py:56 +#: ops/apps.py:9 ops/notifications.py:16 rbac/tree.py:55 msgid "App ops" msgstr "作业中心" @@ -3822,59 +3823,63 @@ msgstr "角色显示" msgid "Has bound this role" msgstr "已经绑定" -#: rbac/tree.py:18 rbac/tree.py:19 +#: rbac/tree.py:17 rbac/tree.py:18 msgid "All permissions" msgstr "所有权限" -#: rbac/tree.py:25 +#: rbac/tree.py:24 msgid "Console view" msgstr "控制台" -#: rbac/tree.py:26 +#: rbac/tree.py:25 msgid "Workbench view" msgstr "工作台" -#: rbac/tree.py:27 +#: rbac/tree.py:26 msgid "Audit view" msgstr "审计台" -#: rbac/tree.py:28 settings/models.py:159 +#: rbac/tree.py:27 settings/models.py:159 msgid "System setting" msgstr "系统设置" -#: rbac/tree.py:29 +#: rbac/tree.py:28 msgid "Other" msgstr "其它" -#: rbac/tree.py:38 +#: rbac/tree.py:37 msgid "Session audits" msgstr "会话审计" -#: rbac/tree.py:48 +#: rbac/tree.py:47 msgid "Cloud import" msgstr "云同步" -#: rbac/tree.py:49 +#: rbac/tree.py:48 msgid "Backup account" msgstr "备份账号" -#: rbac/tree.py:52 +#: rbac/tree.py:49 +msgid "Gather account" +msgstr "收集账号" + +#: rbac/tree.py:51 msgid "Asset change auth" msgstr "资产改密" -#: rbac/tree.py:53 +#: rbac/tree.py:52 msgid "Terminal setting" msgstr "终端设置" -#: rbac/tree.py:54 +#: rbac/tree.py:53 msgid "Task Center" msgstr "任务中心" -#: rbac/tree.py:55 +#: rbac/tree.py:54 msgid "My assets" msgstr "我的资产" -#: rbac/tree.py:57 terminal/models/applet/applet.py:43 +#: rbac/tree.py:56 terminal/models/applet/applet.py:43 #: terminal/models/applet/applet.py:154 terminal/models/applet/host.py:28 #: terminal/serializers/applet.py:15 msgid "Applet" @@ -4373,7 +4378,7 @@ msgid "SSO auth key TTL" msgstr "令牌有效期" #: settings/serializers/auth/sso.py:17 -#: xpack/plugins/cloud/serializers/account_attrs.py:176 +#: xpack/plugins/cloud/serializers/account_attrs.py:184 msgid "Unit: second" msgstr "单位: 秒" @@ -5751,7 +5756,7 @@ msgstr "Access key ID(AK)" msgid "Access key secret" msgstr "Access key secret(SK)" -#: terminal/serializers/storage.py:65 xpack/plugins/cloud/models.py:217 +#: terminal/serializers/storage.py:65 xpack/plugins/cloud/models.py:209 msgid "Region" msgstr "地域" @@ -6864,55 +6869,47 @@ msgstr "地域" msgid "Hostname strategy" msgstr "主机名策略" -#: xpack/plugins/cloud/models.py:100 -msgid "Unix admin user" -msgstr "Unix 管理员" - -#: xpack/plugins/cloud/models.py:104 -msgid "Windows admin user" -msgstr "Windows 管理员" - -#: xpack/plugins/cloud/models.py:110 xpack/plugins/cloud/serializers/task.py:41 +#: xpack/plugins/cloud/models.py:102 xpack/plugins/cloud/serializers/task.py:40 msgid "IP network segment group" msgstr "IP网段组" -#: xpack/plugins/cloud/models.py:113 xpack/plugins/cloud/serializers/task.py:46 +#: xpack/plugins/cloud/models.py:105 xpack/plugins/cloud/serializers/task.py:45 msgid "Sync IP type" msgstr "同步IP类型" -#: xpack/plugins/cloud/models.py:116 xpack/plugins/cloud/serializers/task.py:64 +#: xpack/plugins/cloud/models.py:108 xpack/plugins/cloud/serializers/task.py:62 msgid "Always update" msgstr "总是更新" -#: xpack/plugins/cloud/models.py:122 +#: xpack/plugins/cloud/models.py:114 msgid "Date last sync" msgstr "最后同步日期" -#: xpack/plugins/cloud/models.py:127 xpack/plugins/cloud/models.py:168 +#: xpack/plugins/cloud/models.py:119 xpack/plugins/cloud/models.py:160 msgid "Sync instance task" msgstr "同步实例任务" -#: xpack/plugins/cloud/models.py:179 xpack/plugins/cloud/models.py:227 +#: xpack/plugins/cloud/models.py:171 xpack/plugins/cloud/models.py:219 msgid "Date sync" msgstr "同步日期" -#: xpack/plugins/cloud/models.py:183 +#: xpack/plugins/cloud/models.py:175 msgid "Sync instance task execution" msgstr "同步实例任务执行" -#: xpack/plugins/cloud/models.py:207 +#: xpack/plugins/cloud/models.py:199 msgid "Sync task" msgstr "同步任务" -#: xpack/plugins/cloud/models.py:211 +#: xpack/plugins/cloud/models.py:203 msgid "Sync instance task history" msgstr "同步实例任务历史" -#: xpack/plugins/cloud/models.py:214 +#: xpack/plugins/cloud/models.py:206 msgid "Instance" msgstr "实例" -#: xpack/plugins/cloud/models.py:231 +#: xpack/plugins/cloud/models.py:223 msgid "Sync instance detail" msgstr "同步实例详情" @@ -7126,52 +7123,52 @@ msgstr "租户 ID" msgid "Subscription ID" msgstr "订阅 ID" -#: xpack/plugins/cloud/serializers/account_attrs.py:95 -#: xpack/plugins/cloud/serializers/account_attrs.py:100 -#: xpack/plugins/cloud/serializers/account_attrs.py:116 -#: xpack/plugins/cloud/serializers/account_attrs.py:141 +#: xpack/plugins/cloud/serializers/account_attrs.py:98 +#: xpack/plugins/cloud/serializers/account_attrs.py:103 +#: xpack/plugins/cloud/serializers/account_attrs.py:119 +#: xpack/plugins/cloud/serializers/account_attrs.py:149 msgid "API Endpoint" msgstr "API 端点" -#: xpack/plugins/cloud/serializers/account_attrs.py:106 +#: xpack/plugins/cloud/serializers/account_attrs.py:109 msgid "Auth url" msgstr "认证地址" -#: xpack/plugins/cloud/serializers/account_attrs.py:107 +#: xpack/plugins/cloud/serializers/account_attrs.py:110 msgid "eg: http://openstack.example.com:5000/v3" msgstr "如: http://openstack.example.com:5000/v3" -#: xpack/plugins/cloud/serializers/account_attrs.py:110 +#: xpack/plugins/cloud/serializers/account_attrs.py:113 msgid "User domain" msgstr "用户域" -#: xpack/plugins/cloud/serializers/account_attrs.py:117 +#: xpack/plugins/cloud/serializers/account_attrs.py:120 msgid "Cert File" msgstr "证书文件" -#: xpack/plugins/cloud/serializers/account_attrs.py:118 +#: xpack/plugins/cloud/serializers/account_attrs.py:121 msgid "Key File" msgstr "密钥文件" -#: xpack/plugins/cloud/serializers/account_attrs.py:134 +#: xpack/plugins/cloud/serializers/account_attrs.py:137 msgid "Service account key" msgstr "服务账号密钥" -#: xpack/plugins/cloud/serializers/account_attrs.py:135 +#: xpack/plugins/cloud/serializers/account_attrs.py:138 msgid "The file is in JSON format" msgstr "JSON 格式的文件" -#: xpack/plugins/cloud/serializers/account_attrs.py:148 +#: xpack/plugins/cloud/serializers/account_attrs.py:156 msgid "IP address invalid `{}`, {}" msgstr "IP 地址无效: `{}`, {}" -#: xpack/plugins/cloud/serializers/account_attrs.py:154 +#: xpack/plugins/cloud/serializers/account_attrs.py:162 msgid "" "Format for comma-delimited string,Such as: 192.168.1.0/24, " "10.0.0.0-10.0.0.255" msgstr "格式为逗号分隔的字符串,如:192.168.1.0/24,10.0.0.0-10.0.0.255" -#: xpack/plugins/cloud/serializers/account_attrs.py:158 +#: xpack/plugins/cloud/serializers/account_attrs.py:166 msgid "" "The port is used to detect the validity of the IP address. When the " "synchronization task is executed, only the valid IP address will be " @@ -7180,19 +7177,19 @@ msgstr "" "端口用来检测 IP 地址的有效性,在同步任务执行时,只会同步有效的 IP 地址。
" "如果端口为 0,则表示所有 IP 地址均有效。" -#: xpack/plugins/cloud/serializers/account_attrs.py:166 +#: xpack/plugins/cloud/serializers/account_attrs.py:174 msgid "Hostname prefix" msgstr "主机名前缀" -#: xpack/plugins/cloud/serializers/account_attrs.py:169 +#: xpack/plugins/cloud/serializers/account_attrs.py:177 msgid "IP segment" msgstr "IP 网段" -#: xpack/plugins/cloud/serializers/account_attrs.py:173 +#: xpack/plugins/cloud/serializers/account_attrs.py:181 msgid "Test port" msgstr "测试端口" -#: xpack/plugins/cloud/serializers/account_attrs.py:176 +#: xpack/plugins/cloud/serializers/account_attrs.py:184 msgid "Test timeout" msgstr "测试超时时间" @@ -7216,9 +7213,13 @@ msgstr "执行次数" msgid "Instance count" msgstr "实例个数" -#: xpack/plugins/cloud/serializers/task.py:63 -msgid "Linux admin user" -msgstr "Linux 管理员" +#: xpack/plugins/cloud/tasks.py:27 +msgid "Run sync instance task" +msgstr "执行同步实例任务" + +#: xpack/plugins/cloud/tasks.py:41 +msgid "Period clean sync instance task execution" +msgstr "定期清除同步实例任务执行记录" #: xpack/plugins/cloud/utils.py:69 msgid "Account unavailable" @@ -7288,11 +7289,14 @@ msgstr "旗舰版" msgid "Community edition" msgstr "社区版" -#~ msgid "Run sync instance task" -#~ msgstr "执行同步实例任务" +#~ msgid "Unix admin user" +#~ msgstr "Unix 管理员" -#~ msgid "Period clean sync instance task execution" -#~ msgstr "定期清除同步实例任务执行记录" +#~ msgid "Windows admin user" +#~ msgstr "Windows 管理员" + +#~ msgid "Linux admin user" +#~ msgstr "Linux 管理员" #~ msgid "Can push account to asset" #~ msgstr "可以推送账号到资产" diff --git a/apps/rbac/tree.py b/apps/rbac/tree.py index 1fffdf453..1c9673162 100644 --- a/apps/rbac/tree.py +++ b/apps/rbac/tree.py @@ -1,14 +1,13 @@ #!/usr/bin/python -import os from typing import Callable + +from django.apps import apps +from django.conf import settings +from django.db.models import F +from django.utils.translation import gettext_lazy as _, gettext, get_language from treelib import Tree from treelib.exceptions import NodeIDAbsentError -from django.utils.translation import gettext_lazy as _, gettext, get_language -from django.conf import settings -from django.apps import apps -from django.db.models import F, Count - from common.tree import TreeNode from .models import Permission, ContentType @@ -77,6 +76,7 @@ special_pid_mapper = { "accounts.pushaccountautomation": "push_account_node", "accounts.view_pushaccountexecution": "push_account_node", "accounts.add_pushaccountexecution": "push_account_node", + "accounts.gatheredaccount": "gather_account_node", "accounts.gatheraccountsautomation": "gather_account_node", "accounts.view_gatheraccountsexecution": "gather_account_node", "accounts.add_gatheraccountsexecution": "gather_account_node", From b797b46ab84a5bb3cab7af353e6c66347a8e1e78 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 23 Feb 2023 18:14:44 +0800 Subject: [PATCH 14/21] perf: translate (#9724) Co-authored-by: feng <1304903146@qq.com> --- apps/locale/ja/LC_MESSAGES/django.mo | 4 +- apps/locale/ja/LC_MESSAGES/django.po | 86 ++++++++++++++-------------- apps/locale/zh/LC_MESSAGES/django.mo | 4 +- apps/locale/zh/LC_MESSAGES/django.po | 86 ++++++++++++++-------------- 4 files changed, 90 insertions(+), 90 deletions(-) diff --git a/apps/locale/ja/LC_MESSAGES/django.mo b/apps/locale/ja/LC_MESSAGES/django.mo index 4385e4c98..cfe8bd469 100644 --- a/apps/locale/ja/LC_MESSAGES/django.mo +++ b/apps/locale/ja/LC_MESSAGES/django.mo @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fa23550c6fd74b0f0e586990eb5eb54f2717db9f2e6b0513151d205a34fa2383 -size 136199 +oid sha256:8c2600b7094db2a9e64862169ff1c826d5064fae9b9e71744545a1cea88cbc65 +size 136280 diff --git a/apps/locale/ja/LC_MESSAGES/django.po b/apps/locale/ja/LC_MESSAGES/django.po index 4de6c1775..e3550e3b3 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-02-23 17:59+0800\n" +"POT-Creation-Date: 2023-02-23 18:12+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -195,7 +195,7 @@ msgstr "ソース" #: accounts/serializers/automations/change_secret.py:112 #: accounts/serializers/automations/change_secret.py:132 #: acls/models/base.py:102 acls/serializers/base.py:57 -#: assets/serializers/asset/common.py:125 assets/serializers/gateway.py:28 +#: assets/serializers/asset/common.py:124 assets/serializers/gateway.py:28 #: audits/models.py:49 ops/models/base.py:18 #: perms/models/asset_permission.py:70 perms/serializers/permission.py:32 #: terminal/backends/command/models.py:21 terminal/models/session/session.py:34 @@ -446,7 +446,7 @@ msgstr "アカウントの確認" #: assets/models/cmd_filter.py:21 assets/models/domain.py:18 #: assets/models/group.py:20 assets/models/label.py:18 #: assets/models/platform.py:21 assets/models/platform.py:76 -#: assets/serializers/asset/common.py:68 assets/serializers/asset/common.py:142 +#: assets/serializers/asset/common.py:67 assets/serializers/asset/common.py:142 #: assets/serializers/platform.py:91 assets/serializers/platform.py:136 #: authentication/serializers/connect_token_secret.py:103 ops/mixin.py:21 #: ops/models/adhoc.py:21 ops/models/celery.py:15 ops/models/celery.py:57 @@ -516,12 +516,12 @@ msgstr "" "情報にアクセスしてください-> ファイル暗号化パスワードを設定してください" #: accounts/serializers/account/account.py:65 -#: assets/serializers/asset/common.py:66 settings/serializers/auth/sms.py:75 +#: assets/serializers/asset/common.py:65 settings/serializers/auth/sms.py:75 msgid "Template" msgstr "テンプレート" #: accounts/serializers/account/account.py:68 -#: assets/serializers/asset/common.py:63 +#: assets/serializers/asset/common.py:62 msgid "Push now" msgstr "今すぐプッシュ" @@ -532,9 +532,9 @@ msgstr "エスクローされたパスワード" #: accounts/serializers/account/account.py:75 applications/models.py:11 #: assets/models/label.py:21 assets/models/platform.py:77 -#: assets/serializers/asset/common.py:121 assets/serializers/cagegory.py:8 +#: assets/serializers/asset/common.py:120 assets/serializers/cagegory.py:8 #: assets/serializers/platform.py:97 assets/serializers/platform.py:137 -#: perms/serializers/user_permission.py:25 settings/models.py:35 +#: perms/serializers/user_permission.py:26 settings/models.py:35 #: tickets/models/ticket/apply_application.py:13 msgid "Category" msgstr "カテゴリ" @@ -544,10 +544,10 @@ msgstr "カテゴリ" #: acls/serializers/command_acl.py:18 applications/models.py:14 #: assets/models/_user.py:50 assets/models/automations/base.py:20 #: assets/models/cmd_filter.py:74 assets/models/platform.py:78 -#: assets/serializers/asset/common.py:122 assets/serializers/platform.py:96 +#: assets/serializers/asset/common.py:121 assets/serializers/platform.py:96 #: audits/serializers.py:48 #: authentication/serializers/connect_token_secret.py:116 ops/models/job.py:102 -#: perms/serializers/user_permission.py:26 terminal/models/applet/applet.py:31 +#: perms/serializers/user_permission.py:27 terminal/models/applet/applet.py:31 #: terminal/models/component/storage.py:57 #: terminal/models/component/storage.py:146 terminal/serializers/applet.py:29 #: terminal/serializers/session.py:22 terminal/serializers/storage.py:224 @@ -998,7 +998,7 @@ msgid "Device" msgstr "インターネット機器" #: assets/const/category.py:13 assets/models/asset/database.py:9 -#: assets/models/asset/database.py:24 assets/serializers/asset/common.py:109 +#: assets/models/asset/database.py:24 assets/serializers/asset/common.py:108 msgid "Database" msgstr "データベース" @@ -1041,13 +1041,12 @@ msgstr "Webサイト" msgid "Disabled" msgstr "無効" -#: assets/const/web.py:60 settings/serializers/auth/base.py:10 -#: settings/serializers/basic.py:27 +#: assets/const/web.py:60 settings/serializers/basic.py:27 msgid "Basic" msgstr "基本" #: assets/const/web.py:61 assets/models/asset/web.py:13 -#: assets/serializers/asset/common.py:117 assets/serializers/platform.py:40 +#: assets/serializers/asset/common.py:116 assets/serializers/platform.py:40 msgid "Script" msgstr "脚本" @@ -1182,14 +1181,14 @@ msgstr "アドレス" #: assets/models/asset/common.py:104 assets/models/platform.py:112 #: authentication/serializers/connect_token_secret.py:108 -#: perms/serializers/user_permission.py:23 +#: perms/serializers/user_permission.py:24 #: xpack/plugins/cloud/serializers/account_attrs.py:187 msgid "Platform" msgstr "プラットフォーム" #: assets/models/asset/common.py:106 assets/models/domain.py:21 #: authentication/serializers/connect_token_secret.py:126 -#: perms/serializers/user_permission.py:27 +#: perms/serializers/user_permission.py:28 msgid "Domain" msgstr "ドメイン" @@ -1213,7 +1212,7 @@ msgstr "アセットを一致させることができます" msgid "Can change asset nodes" msgstr "資産ノードを変更できます" -#: assets/models/asset/database.py:10 assets/serializers/asset/common.py:110 +#: assets/models/asset/database.py:10 assets/serializers/asset/common.py:109 #: settings/serializers/email.py:37 msgid "Use SSL" msgstr "SSLの使用" @@ -1230,7 +1229,7 @@ msgstr "クライアント証明書" msgid "Client key" msgstr "クライアントキー" -#: assets/models/asset/database.py:14 assets/serializers/asset/common.py:111 +#: assets/models/asset/database.py:14 assets/serializers/asset/common.py:110 msgid "Allow invalid cert" msgstr "証明書チェックを無視" @@ -1238,17 +1237,17 @@ msgstr "証明書チェックを無視" msgid "Autofill" msgstr "自動充填" -#: assets/models/asset/web.py:10 assets/serializers/asset/common.py:114 +#: assets/models/asset/web.py:10 assets/serializers/asset/common.py:113 #: assets/serializers/platform.py:32 msgid "Username selector" msgstr "ユーザー名ピッカー" -#: assets/models/asset/web.py:11 assets/serializers/asset/common.py:115 +#: assets/models/asset/web.py:11 assets/serializers/asset/common.py:114 #: assets/serializers/platform.py:35 msgid "Password selector" msgstr "パスワードセレクター" -#: assets/models/asset/web.py:12 assets/serializers/asset/common.py:116 +#: assets/models/asset/web.py:12 assets/serializers/asset/common.py:115 #: assets/serializers/platform.py:38 msgid "Submit selector" msgstr "ボタンセレクターを確認する" @@ -1356,7 +1355,7 @@ msgstr "システム" msgid "Value" msgstr "値" -#: assets/models/label.py:40 assets/serializers/asset/common.py:123 +#: assets/models/label.py:40 assets/serializers/asset/common.py:122 #: assets/serializers/cagegory.py:6 assets/serializers/cagegory.py:13 #: authentication/serializers/connect_token_secret.py:114 #: common/serializers/common.py:79 settings/serializers/sms.py:7 @@ -1396,7 +1395,7 @@ msgstr "ノードを一致させることができます" msgid "Required" msgstr "必要" -#: assets/models/platform.py:23 settings/serializers/settings.py:61 +#: assets/models/platform.py:23 settings/serializers/settings.py:65 #: users/templates/users/reset_password.html:29 msgid "Setting" msgstr "設定" @@ -1485,14 +1484,14 @@ msgstr "オートメーション" msgid "%(value)s is not an even number" msgstr "%(value)s は偶数ではありません" -#: assets/serializers/asset/common.py:113 +#: assets/serializers/asset/common.py:112 msgid "Auto fill" msgstr "自動充填" -#: assets/serializers/asset/common.py:124 assets/serializers/platform.py:99 +#: assets/serializers/asset/common.py:123 assets/serializers/platform.py:99 #: authentication/serializers/connect_token_secret.py:28 #: authentication/serializers/connect_token_secret.py:66 -#: perms/serializers/user_permission.py:24 xpack/plugins/cloud/models.py:99 +#: perms/serializers/user_permission.py:25 xpack/plugins/cloud/models.py:99 msgid "Protocols" msgstr "プロトコル" @@ -1824,11 +1823,12 @@ msgstr "ファイル名" msgid "File transfer log" msgstr "ファイル転送ログ" -#: audits/models.py:67 +#: audits/models.py:67 audits/serializers.py:84 msgid "Resource Type" msgstr "リソースタイプ" #: audits/models.py:68 audits/models.py:71 audits/models.py:117 +#: audits/serializers.py:83 msgid "Resource" msgstr "リソース" @@ -1902,7 +1902,7 @@ msgstr "ユーザーログインログ" msgid "Reason display" msgstr "理由表示" -#: audits/serializers.py:122 +#: audits/serializers.py:132 #, python-format msgid "User %s %s this resource" msgstr "ユーザー %s %s が現在のリソースをサブスクライブしました。" @@ -2013,11 +2013,6 @@ msgid "Forgot password" msgstr "パスワードを忘れた" #: authentication/apps.py:7 settings/serializers/auth/base.py:10 -#: settings/serializers/auth/cas.py:10 settings/serializers/auth/dingtalk.py:10 -#: settings/serializers/auth/feishu.py:10 settings/serializers/auth/ldap.py:39 -#: settings/serializers/auth/oauth2.py:18 settings/serializers/auth/oidc.py:12 -#: settings/serializers/auth/radius.py:13 settings/serializers/auth/saml2.py:11 -#: settings/serializers/auth/sso.py:10 settings/serializers/auth/wecom.py:10 msgid "Authentication" msgstr "認証" @@ -3127,15 +3122,15 @@ msgstr "特殊文字を含むべきではない" msgid "The mobile phone number format is incorrect" msgstr "携帯電話番号の形式が正しくありません" -#: common/views/mixins.py:57 +#: common/views/mixins.py:58 msgid "Export all" msgstr "すべてエクスポート" -#: common/views/mixins.py:59 +#: common/views/mixins.py:60 msgid "Export only selected items" msgstr "選択項目のみエクスポート" -#: common/views/mixins.py:64 +#: common/views/mixins.py:65 #, python-format msgid "Export filtered: %s" msgstr "検索のエクスポート: %s" @@ -3369,7 +3364,7 @@ msgid "Date last run" msgstr "最終実行日" #: ops/models/base.py:51 ops/models/job.py:187 -#: xpack/plugins/cloud/models.py:170 +#: xpack/plugins/cloud/models.py:162 msgid "Result" msgstr "結果" @@ -4939,6 +4934,11 @@ msgstr "" "します。アカウントが共通のログイン都市からログインしている場合、システムはリ" "モートログインリマインダーを送信します" +#: settings/serializers/settings.py:69 +#, python-format +msgid "[%s] %s" +msgstr "" + #: settings/serializers/terminal.py:9 msgid "Hostname" msgstr "ホスト名" @@ -7328,31 +7328,31 @@ msgstr "デフォルトの復元に成功しました。" msgid "Interface settings" msgstr "インターフェイスの設定" -#: xpack/plugins/interface/models.py:22 +#: xpack/plugins/interface/models.py:23 msgid "Title of login page" msgstr "ログインページのタイトル" -#: xpack/plugins/interface/models.py:26 +#: xpack/plugins/interface/models.py:27 msgid "Image of login page" msgstr "ログインページのイメージ" -#: xpack/plugins/interface/models.py:30 +#: xpack/plugins/interface/models.py:31 msgid "Website icon" msgstr "ウェブサイトのアイコン" -#: xpack/plugins/interface/models.py:34 +#: xpack/plugins/interface/models.py:35 msgid "Logo of management page" msgstr "管理ページのロゴ" -#: xpack/plugins/interface/models.py:38 +#: xpack/plugins/interface/models.py:39 msgid "Logo of logout page" msgstr "ログアウトページのロゴ" -#: xpack/plugins/interface/models.py:40 +#: xpack/plugins/interface/models.py:41 msgid "Theme" msgstr "テーマ" -#: xpack/plugins/interface/models.py:43 xpack/plugins/interface/models.py:84 +#: xpack/plugins/interface/models.py:44 xpack/plugins/interface/models.py:85 msgid "Interface setting" msgstr "インターフェイスの設定" diff --git a/apps/locale/zh/LC_MESSAGES/django.mo b/apps/locale/zh/LC_MESSAGES/django.mo index 45bd3cbec..11c2ca99d 100644 --- a/apps/locale/zh/LC_MESSAGES/django.mo +++ b/apps/locale/zh/LC_MESSAGES/django.mo @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a1627f904e2932024a40fe6548e9be4a1d5d4890b7915843b91f6e83b04cc77d -size 111903 +oid sha256:a29193d2982b254444285cfb2d61f7ef7355ae2bab181cdf366446e879ab32fb +size 111963 diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index 854c7e0d5..b282e761a 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-02-23 17:59+0800\n" +"POT-Creation-Date: 2023-02-23 18:12+0800\n" "PO-Revision-Date: 2021-05-20 10:54+0800\n" "Last-Translator: ibuler \n" "Language-Team: JumpServer team\n" @@ -194,7 +194,7 @@ msgstr "来源" #: accounts/serializers/automations/change_secret.py:112 #: accounts/serializers/automations/change_secret.py:132 #: acls/models/base.py:102 acls/serializers/base.py:57 -#: assets/serializers/asset/common.py:125 assets/serializers/gateway.py:28 +#: assets/serializers/asset/common.py:124 assets/serializers/gateway.py:28 #: audits/models.py:49 ops/models/base.py:18 #: perms/models/asset_permission.py:70 perms/serializers/permission.py:32 #: terminal/backends/command/models.py:21 terminal/models/session/session.py:34 @@ -445,7 +445,7 @@ msgstr "账号验证" #: assets/models/cmd_filter.py:21 assets/models/domain.py:18 #: assets/models/group.py:20 assets/models/label.py:18 #: assets/models/platform.py:21 assets/models/platform.py:76 -#: assets/serializers/asset/common.py:68 assets/serializers/asset/common.py:142 +#: assets/serializers/asset/common.py:67 assets/serializers/asset/common.py:142 #: assets/serializers/platform.py:91 assets/serializers/platform.py:136 #: authentication/serializers/connect_token_secret.py:103 ops/mixin.py:21 #: ops/models/adhoc.py:21 ops/models/celery.py:15 ops/models/celery.py:57 @@ -512,12 +512,12 @@ msgstr "" "密密码" #: accounts/serializers/account/account.py:65 -#: assets/serializers/asset/common.py:66 settings/serializers/auth/sms.py:75 +#: assets/serializers/asset/common.py:65 settings/serializers/auth/sms.py:75 msgid "Template" msgstr "模板" #: accounts/serializers/account/account.py:68 -#: assets/serializers/asset/common.py:63 +#: assets/serializers/asset/common.py:62 msgid "Push now" msgstr "立即推送" @@ -528,9 +528,9 @@ msgstr "已托管密码" #: accounts/serializers/account/account.py:75 applications/models.py:11 #: assets/models/label.py:21 assets/models/platform.py:77 -#: assets/serializers/asset/common.py:121 assets/serializers/cagegory.py:8 +#: assets/serializers/asset/common.py:120 assets/serializers/cagegory.py:8 #: assets/serializers/platform.py:97 assets/serializers/platform.py:137 -#: perms/serializers/user_permission.py:25 settings/models.py:35 +#: perms/serializers/user_permission.py:26 settings/models.py:35 #: tickets/models/ticket/apply_application.py:13 msgid "Category" msgstr "类别" @@ -540,10 +540,10 @@ msgstr "类别" #: acls/serializers/command_acl.py:18 applications/models.py:14 #: assets/models/_user.py:50 assets/models/automations/base.py:20 #: assets/models/cmd_filter.py:74 assets/models/platform.py:78 -#: assets/serializers/asset/common.py:122 assets/serializers/platform.py:96 +#: assets/serializers/asset/common.py:121 assets/serializers/platform.py:96 #: audits/serializers.py:48 #: authentication/serializers/connect_token_secret.py:116 ops/models/job.py:102 -#: perms/serializers/user_permission.py:26 terminal/models/applet/applet.py:31 +#: perms/serializers/user_permission.py:27 terminal/models/applet/applet.py:31 #: terminal/models/component/storage.py:57 #: terminal/models/component/storage.py:146 terminal/serializers/applet.py:29 #: terminal/serializers/session.py:22 terminal/serializers/storage.py:224 @@ -990,7 +990,7 @@ msgid "Device" msgstr "网络设备" #: assets/const/category.py:13 assets/models/asset/database.py:9 -#: assets/models/asset/database.py:24 assets/serializers/asset/common.py:109 +#: assets/models/asset/database.py:24 assets/serializers/asset/common.py:108 msgid "Database" msgstr "数据库" @@ -1033,13 +1033,12 @@ msgstr "网站" msgid "Disabled" msgstr "禁用" -#: assets/const/web.py:60 settings/serializers/auth/base.py:10 -#: settings/serializers/basic.py:27 +#: assets/const/web.py:60 settings/serializers/basic.py:27 msgid "Basic" msgstr "基本" #: assets/const/web.py:61 assets/models/asset/web.py:13 -#: assets/serializers/asset/common.py:117 assets/serializers/platform.py:40 +#: assets/serializers/asset/common.py:116 assets/serializers/platform.py:40 msgid "Script" msgstr "脚本" @@ -1174,14 +1173,14 @@ msgstr "地址" #: assets/models/asset/common.py:104 assets/models/platform.py:112 #: authentication/serializers/connect_token_secret.py:108 -#: perms/serializers/user_permission.py:23 +#: perms/serializers/user_permission.py:24 #: xpack/plugins/cloud/serializers/account_attrs.py:187 msgid "Platform" msgstr "系统平台" #: assets/models/asset/common.py:106 assets/models/domain.py:21 #: authentication/serializers/connect_token_secret.py:126 -#: perms/serializers/user_permission.py:27 +#: perms/serializers/user_permission.py:28 msgid "Domain" msgstr "网域" @@ -1205,7 +1204,7 @@ msgstr "可以匹配资产" msgid "Can change asset nodes" msgstr "可以修改资产节点" -#: assets/models/asset/database.py:10 assets/serializers/asset/common.py:110 +#: assets/models/asset/database.py:10 assets/serializers/asset/common.py:109 #: settings/serializers/email.py:37 msgid "Use SSL" msgstr "使用 SSL" @@ -1222,7 +1221,7 @@ msgstr "客户端证书" msgid "Client key" msgstr "客户端密钥" -#: assets/models/asset/database.py:14 assets/serializers/asset/common.py:111 +#: assets/models/asset/database.py:14 assets/serializers/asset/common.py:110 msgid "Allow invalid cert" msgstr "忽略证书校验" @@ -1230,17 +1229,17 @@ msgstr "忽略证书校验" msgid "Autofill" msgstr "自动代填" -#: assets/models/asset/web.py:10 assets/serializers/asset/common.py:114 +#: assets/models/asset/web.py:10 assets/serializers/asset/common.py:113 #: assets/serializers/platform.py:32 msgid "Username selector" msgstr "用户名选择器" -#: assets/models/asset/web.py:11 assets/serializers/asset/common.py:115 +#: assets/models/asset/web.py:11 assets/serializers/asset/common.py:114 #: assets/serializers/platform.py:35 msgid "Password selector" msgstr "密码选择器" -#: assets/models/asset/web.py:12 assets/serializers/asset/common.py:116 +#: assets/models/asset/web.py:12 assets/serializers/asset/common.py:115 #: assets/serializers/platform.py:38 msgid "Submit selector" msgstr "确认按钮选择器" @@ -1348,7 +1347,7 @@ msgstr "系统" msgid "Value" msgstr "值" -#: assets/models/label.py:40 assets/serializers/asset/common.py:123 +#: assets/models/label.py:40 assets/serializers/asset/common.py:122 #: assets/serializers/cagegory.py:6 assets/serializers/cagegory.py:13 #: authentication/serializers/connect_token_secret.py:114 #: common/serializers/common.py:79 settings/serializers/sms.py:7 @@ -1388,7 +1387,7 @@ msgstr "可以匹配节点" msgid "Required" msgstr "必须的" -#: assets/models/platform.py:23 settings/serializers/settings.py:61 +#: assets/models/platform.py:23 settings/serializers/settings.py:65 #: users/templates/users/reset_password.html:29 msgid "Setting" msgstr "设置" @@ -1477,14 +1476,14 @@ msgstr "自动化" msgid "%(value)s is not an even number" msgstr "%(value)s is not an even number" -#: assets/serializers/asset/common.py:113 +#: assets/serializers/asset/common.py:112 msgid "Auto fill" msgstr "自动代填" -#: assets/serializers/asset/common.py:124 assets/serializers/platform.py:99 +#: assets/serializers/asset/common.py:123 assets/serializers/platform.py:99 #: authentication/serializers/connect_token_secret.py:28 #: authentication/serializers/connect_token_secret.py:66 -#: perms/serializers/user_permission.py:24 xpack/plugins/cloud/models.py:99 +#: perms/serializers/user_permission.py:25 xpack/plugins/cloud/models.py:99 msgid "Protocols" msgstr "协议组" @@ -1814,11 +1813,12 @@ msgstr "文件名" msgid "File transfer log" msgstr "文件管理" -#: audits/models.py:67 +#: audits/models.py:67 audits/serializers.py:84 msgid "Resource Type" msgstr "资源类型" #: audits/models.py:68 audits/models.py:71 audits/models.py:117 +#: audits/serializers.py:83 msgid "Resource" msgstr "资源" @@ -1892,7 +1892,7 @@ msgstr "用户登录日志" msgid "Reason display" msgstr "原因描述" -#: audits/serializers.py:122 +#: audits/serializers.py:132 #, python-format msgid "User %s %s this resource" msgstr "用户 %s %s 了当前资源" @@ -2001,11 +2001,6 @@ msgid "Forgot password" msgstr "忘记密码" #: authentication/apps.py:7 settings/serializers/auth/base.py:10 -#: settings/serializers/auth/cas.py:10 settings/serializers/auth/dingtalk.py:10 -#: settings/serializers/auth/feishu.py:10 settings/serializers/auth/ldap.py:39 -#: settings/serializers/auth/oauth2.py:18 settings/serializers/auth/oidc.py:12 -#: settings/serializers/auth/radius.py:13 settings/serializers/auth/saml2.py:11 -#: settings/serializers/auth/sso.py:10 settings/serializers/auth/wecom.py:10 msgid "Authentication" msgstr "认证" @@ -3097,15 +3092,15 @@ msgstr "不能包含特殊字符" msgid "The mobile phone number format is incorrect" msgstr "手机号格式不正确" -#: common/views/mixins.py:57 +#: common/views/mixins.py:58 msgid "Export all" msgstr "导出所有" -#: common/views/mixins.py:59 +#: common/views/mixins.py:60 msgid "Export only selected items" msgstr "仅导出选择项" -#: common/views/mixins.py:64 +#: common/views/mixins.py:65 #, python-format msgid "Export filtered: %s" msgstr "导出搜素: %s" @@ -3334,7 +3329,7 @@ msgid "Date last run" msgstr "最后运行日期" #: ops/models/base.py:51 ops/models/job.py:187 -#: xpack/plugins/cloud/models.py:170 +#: xpack/plugins/cloud/models.py:162 msgid "Result" msgstr "结果" @@ -4880,6 +4875,11 @@ msgstr "" "根据登录 IP 是否所属常用登录城市进行判断,若账号在非常用城市登录,会发送异地" "登录提醒" +#: settings/serializers/settings.py:69 +#, python-format +msgid "[%s] %s" +msgstr "" + #: settings/serializers/terminal.py:9 msgid "Hostname" msgstr "主机名" @@ -7233,31 +7233,31 @@ msgstr "恢复默认成功!" msgid "Interface settings" msgstr "界面设置" -#: xpack/plugins/interface/models.py:22 +#: xpack/plugins/interface/models.py:23 msgid "Title of login page" msgstr "登录页面标题" -#: xpack/plugins/interface/models.py:26 +#: xpack/plugins/interface/models.py:27 msgid "Image of login page" msgstr "登录页面图片" -#: xpack/plugins/interface/models.py:30 +#: xpack/plugins/interface/models.py:31 msgid "Website icon" msgstr "网站图标" -#: xpack/plugins/interface/models.py:34 +#: xpack/plugins/interface/models.py:35 msgid "Logo of management page" msgstr "管理页面logo" -#: xpack/plugins/interface/models.py:38 +#: xpack/plugins/interface/models.py:39 msgid "Logo of logout page" msgstr "退出页面logo" -#: xpack/plugins/interface/models.py:40 +#: xpack/plugins/interface/models.py:41 msgid "Theme" msgstr "主题" -#: xpack/plugins/interface/models.py:43 xpack/plugins/interface/models.py:84 +#: xpack/plugins/interface/models.py:44 xpack/plugins/interface/models.py:85 msgid "Interface setting" msgstr "界面设置" From e45eb96f12b72902a2f837b362407185c642201d Mon Sep 17 00:00:00 2001 From: jiangweidong Date: Thu, 23 Feb 2023 18:15:31 +0800 Subject: [PATCH 15/21] =?UTF-8?q?fix:=20=E5=AF=B9=E4=BA=8E=E7=BD=91?= =?UTF-8?q?=E5=85=B3=E6=97=A0=E6=B3=95=E8=BF=9E=E6=8E=A5=E7=9A=84=EF=BC=8C?= =?UTF-8?q?=E7=BB=99=E5=87=BA=E5=8E=9F=E5=9B=A0=E5=B9=B6=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E6=AD=A4=E4=BB=BB=E5=8A=A1=E7=9A=84=E5=90=8E=E7=BB=AD=E6=AD=A5?= =?UTF-8?q?=E9=AA=A4=EF=BC=8C=E4=B8=8D=E5=BD=B1=E5=93=8D=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/automations/base/manager.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/apps/assets/automations/base/manager.py b/apps/assets/automations/base/manager.py index 98c1afb9d..084ac0c82 100644 --- a/apps/assets/automations/base/manager.py +++ b/apps/assets/automations/base/manager.py @@ -9,7 +9,7 @@ import yaml from django.conf import settings from django.utils import timezone from django.utils.translation import gettext as _ -from sshtunnel import SSHTunnelForwarder +from sshtunnel import SSHTunnelForwarder, BaseSSHTunnelForwarderError from assets.automations.methods import platform_automation_methods from common.utils import get_logger, lazyproperty @@ -229,7 +229,7 @@ class BasePlaybookManager: def local_gateway_prepare(self, runner): info = self.file_to_json(runner.inventory) - servers = [] + servers, not_valid = [], [] for k, host in info['all']['hosts'].items(): jms_asset, jms_gateway = host['jms_asset'], host.get('gateway') if not jms_gateway: @@ -240,10 +240,20 @@ class BasePlaybookManager: ssh_password=jms_gateway['secret'], remote_bind_address=(jms_asset['address'], jms_asset['port']) ) - server.start() - jms_asset['address'] = '127.0.0.1' - jms_asset['port'] = server.local_bind_port - servers.append(server) + try: + server.start() + except BaseSSHTunnelForwarderError: + err_msg = 'Gateway is not active: %s' % jms_asset.get('name', '') + print('\033[31m %s \033[0m\n' % err_msg) + not_valid.append(k) + else: + jms_asset['address'] = '127.0.0.1' + jms_asset['port'] = server.local_bind_port + servers.append(server) + + # 网域不可连接的,就不继续执行此资源的后续任务了 + for a in set(not_valid): + info['all']['hosts'].pop(a) self.json_to_file(runner.inventory, info) self.gateway_servers[runner.id] = servers From ab0a1421a07ba4a71f3d595ae11c67c186fafb1e Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 23 Feb 2023 18:55:15 +0800 Subject: [PATCH 16/21] perf: push_account_enabled (#9727) Co-authored-by: feng <1304903146@qq.com> --- apps/assets/models/asset/common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/assets/models/asset/common.py b/apps/assets/models/asset/common.py index 8460556c4..54fa473bd 100644 --- a/apps/assets/models/asset/common.py +++ b/apps/assets/models/asset/common.py @@ -156,6 +156,7 @@ class Asset(NodesRelationMixin, AbsConnectivity, JMSOrgBaseModel): 'ping_enabled': automation.ping_enabled, 'domain_enabled': platform.domain_enabled, 'ansible_enabled': automation.ansible_enabled, + 'push_account_enabled': automation.push_account_enabled, 'gather_facts_enabled': automation.gather_facts_enabled, 'change_secret_enabled': automation.change_secret_enabled, 'verify_account_enabled': automation.verify_account_enabled, From 37f7f1b510ebf8a1bbb58a66767bdb06d346aa5f Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 23 Feb 2023 19:06:08 +0800 Subject: [PATCH 17/21] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=20celery=20=E6=97=A5=E5=BF=97=E7=9A=84=E6=9D=83?= =?UTF-8?q?=E9=99=90=E4=BD=8D=20(#9728)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Aaron3S --- apps/ops/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/ops/views.py b/apps/ops/views.py index bb07d8cac..85aa94c65 100644 --- a/apps/ops/views.py +++ b/apps/ops/views.py @@ -13,7 +13,7 @@ class CeleryTaskLogView(PermissionsMixin, TemplateView): template_name = 'ops/celery_task_log.html' permission_classes = [RBACPermission] rbac_perms = { - 'GET': 'ops.view_tasklog' + 'GET': 'ops.view_celerytask' } def get_context_data(self, **kwargs): From 0a374db60685cdc54413d930c55dc795e11057cf Mon Sep 17 00:00:00 2001 From: "Jiangjie.Bai" Date: Thu, 23 Feb 2023 19:14:58 +0800 Subject: [PATCH 18/21] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=AF=BC=E5=87=BA=20{"":=20True"}=20=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#9729)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/serializers/asset/common.py | 1 + apps/assets/serializers/asset/host.py | 2 +- apps/common/drf/renders/base.py | 2 ++ apps/locale/ja/LC_MESSAGES/django.po | 41 ++++++++++++++----------- apps/locale/zh/LC_MESSAGES/django.po | 41 ++++++++++++++----------- 5 files changed, 50 insertions(+), 37 deletions(-) diff --git a/apps/assets/serializers/asset/common.py b/apps/assets/serializers/asset/common.py index 01a8bc7b8..1dc6aa28d 100644 --- a/apps/assets/serializers/asset/common.py +++ b/apps/assets/serializers/asset/common.py @@ -139,6 +139,7 @@ class AssetSerializer(BulkOrgResourceModelSerializer, WritableNestedModelSeriali ] fields = fields_small + fields_fk + fields_m2m + read_only_fields extra_kwargs = { + 'auto_info': {'label': _('Auto info')}, 'name': {'label': _("Name")}, 'address': {'label': _('Address')}, 'nodes_display': {'label': _('Node path')}, diff --git a/apps/assets/serializers/asset/host.py b/apps/assets/serializers/asset/host.py index 10b06dc20..6a733c1e3 100644 --- a/apps/assets/serializers/asset/host.py +++ b/apps/assets/serializers/asset/host.py @@ -25,7 +25,7 @@ class HostInfoSerializer(serializers.Serializer): class HostSerializer(AssetSerializer): - info = HostInfoSerializer(required=False) + info = HostInfoSerializer(required=False, label=_('Info')) class Meta(AssetSerializer.Meta): model = Host diff --git a/apps/common/drf/renders/base.py b/apps/common/drf/renders/base.py index 06867ce79..8e1373b9d 100644 --- a/apps/common/drf/renders/base.py +++ b/apps/common/drf/renders/base.py @@ -75,6 +75,8 @@ class BaseFileRenderer(BaseRenderer): value = item.get(field.field_name) if value is None: value = '' + elif isinstance(value, dict): + value = json.dumps(value, ensure_ascii=False) else: value = str(value) row.append(value) diff --git a/apps/locale/ja/LC_MESSAGES/django.po b/apps/locale/ja/LC_MESSAGES/django.po index e3550e3b3..c5cda4241 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-02-23 18:12+0800\n" +"POT-Creation-Date: 2023-02-23 19:11+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -165,7 +165,7 @@ msgstr "作成のみ" #: accounts/serializers/automations/change_secret.py:111 #: accounts/serializers/automations/change_secret.py:131 #: acls/models/base.py:100 acls/serializers/base.py:56 -#: assets/models/asset/common.py:92 assets/models/asset/common.py:279 +#: assets/models/asset/common.py:92 assets/models/asset/common.py:280 #: assets/models/cmd_filter.py:36 assets/serializers/domain.py:19 #: assets/serializers/label.py:27 audits/models.py:48 #: authentication/models/connection_token.py:33 @@ -446,7 +446,7 @@ msgstr "アカウントの確認" #: assets/models/cmd_filter.py:21 assets/models/domain.py:18 #: assets/models/group.py:20 assets/models/label.py:18 #: assets/models/platform.py:21 assets/models/platform.py:76 -#: assets/serializers/asset/common.py:67 assets/serializers/asset/common.py:142 +#: assets/serializers/asset/common.py:67 assets/serializers/asset/common.py:143 #: assets/serializers/platform.py:91 assets/serializers/platform.py:136 #: authentication/serializers/connect_token_secret.py:103 ops/mixin.py:21 #: ops/models/adhoc.py:21 ops/models/celery.py:15 ops/models/celery.py:57 @@ -592,7 +592,7 @@ msgid "Key password" msgstr "キーパスワード" #: accounts/serializers/account/base.py:79 -#: assets/serializers/asset/common.py:290 +#: assets/serializers/asset/common.py:291 msgid "Spec info" msgstr "特別情報" @@ -1175,7 +1175,7 @@ msgstr "クラウド サービス" msgid "Port" msgstr "ポート" -#: assets/models/asset/common.py:103 assets/serializers/asset/common.py:143 +#: assets/models/asset/common.py:103 assets/serializers/asset/common.py:144 msgid "Address" msgstr "アドレス" @@ -1196,19 +1196,19 @@ msgstr "ドメイン" msgid "Labels" msgstr "ラベル" -#: assets/models/asset/common.py:282 +#: assets/models/asset/common.py:283 msgid "Can refresh asset hardware info" msgstr "資産ハードウェア情報を更新できます" -#: assets/models/asset/common.py:283 +#: assets/models/asset/common.py:284 msgid "Can test asset connectivity" msgstr "資産接続をテストできます" -#: assets/models/asset/common.py:284 +#: assets/models/asset/common.py:285 msgid "Can match asset" msgstr "アセットを一致させることができます" -#: assets/models/asset/common.py:285 +#: assets/models/asset/common.py:286 msgid "Can change asset nodes" msgstr "資産ノードを変更できます" @@ -1253,7 +1253,7 @@ msgid "Submit selector" msgstr "ボタンセレクターを確認する" #: assets/models/automations/base.py:17 assets/models/cmd_filter.py:38 -#: assets/serializers/asset/common.py:289 rbac/tree.py:35 +#: assets/serializers/asset/common.py:290 rbac/tree.py:35 msgid "Accounts" msgstr "アカウント" @@ -1495,26 +1495,27 @@ msgstr "自動充填" msgid "Protocols" msgstr "プロトコル" -#: assets/serializers/asset/common.py:144 +#: assets/serializers/asset/common.py:142 +#: assets/serializers/asset/common.py:292 +msgid "Auto info" +msgstr "自動情報" + +#: assets/serializers/asset/common.py:145 msgid "Node path" msgstr "ノードパスです" -#: assets/serializers/asset/common.py:217 +#: assets/serializers/asset/common.py:218 msgid "Platform not exist" msgstr "プラットフォームが存在しません" -#: assets/serializers/asset/common.py:252 +#: assets/serializers/asset/common.py:253 msgid "port out of range (1-65535)" msgstr "ポート番号が範囲外です (1-65535)" -#: assets/serializers/asset/common.py:259 +#: assets/serializers/asset/common.py:260 msgid "Protocol is required: {}" msgstr "プロトコルが必要です: {}" -#: assets/serializers/asset/common.py:291 -msgid "Auto info" -msgstr "自動情報" - #: assets/serializers/asset/database.py:25 common/serializers/fields.py:100 #: tickets/serializers/ticket/common.py:58 #: xpack/plugins/cloud/serializers/account_attrs.py:56 @@ -1572,6 +1573,10 @@ msgstr "システムバージョン" msgid "OS arch" msgstr "システムアーキテクチャ" +#: assets/serializers/asset/host.py:28 +msgid "Info" +msgstr "情報" + #: assets/serializers/cagegory.py:9 msgid "Constraints" msgstr "制約" diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index b282e761a..b8db40723 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-02-23 18:12+0800\n" +"POT-Creation-Date: 2023-02-23 19:11+0800\n" "PO-Revision-Date: 2021-05-20 10:54+0800\n" "Last-Translator: ibuler \n" "Language-Team: JumpServer team\n" @@ -164,7 +164,7 @@ msgstr "仅创建" #: accounts/serializers/automations/change_secret.py:111 #: accounts/serializers/automations/change_secret.py:131 #: acls/models/base.py:100 acls/serializers/base.py:56 -#: assets/models/asset/common.py:92 assets/models/asset/common.py:279 +#: assets/models/asset/common.py:92 assets/models/asset/common.py:280 #: assets/models/cmd_filter.py:36 assets/serializers/domain.py:19 #: assets/serializers/label.py:27 audits/models.py:48 #: authentication/models/connection_token.py:33 @@ -445,7 +445,7 @@ msgstr "账号验证" #: assets/models/cmd_filter.py:21 assets/models/domain.py:18 #: assets/models/group.py:20 assets/models/label.py:18 #: assets/models/platform.py:21 assets/models/platform.py:76 -#: assets/serializers/asset/common.py:67 assets/serializers/asset/common.py:142 +#: assets/serializers/asset/common.py:67 assets/serializers/asset/common.py:143 #: assets/serializers/platform.py:91 assets/serializers/platform.py:136 #: authentication/serializers/connect_token_secret.py:103 ops/mixin.py:21 #: ops/models/adhoc.py:21 ops/models/celery.py:15 ops/models/celery.py:57 @@ -588,7 +588,7 @@ msgid "Key password" msgstr "密钥密码" #: accounts/serializers/account/base.py:79 -#: assets/serializers/asset/common.py:290 +#: assets/serializers/asset/common.py:291 msgid "Spec info" msgstr "特殊信息" @@ -1167,7 +1167,7 @@ msgstr "云服务" msgid "Port" msgstr "端口" -#: assets/models/asset/common.py:103 assets/serializers/asset/common.py:143 +#: assets/models/asset/common.py:103 assets/serializers/asset/common.py:144 msgid "Address" msgstr "地址" @@ -1188,19 +1188,19 @@ msgstr "网域" msgid "Labels" msgstr "标签管理" -#: assets/models/asset/common.py:282 +#: assets/models/asset/common.py:283 msgid "Can refresh asset hardware info" msgstr "可以更新资产硬件信息" -#: assets/models/asset/common.py:283 +#: assets/models/asset/common.py:284 msgid "Can test asset connectivity" msgstr "可以测试资产连接性" -#: assets/models/asset/common.py:284 +#: assets/models/asset/common.py:285 msgid "Can match asset" msgstr "可以匹配资产" -#: assets/models/asset/common.py:285 +#: assets/models/asset/common.py:286 msgid "Can change asset nodes" msgstr "可以修改资产节点" @@ -1245,7 +1245,7 @@ msgid "Submit selector" msgstr "确认按钮选择器" #: assets/models/automations/base.py:17 assets/models/cmd_filter.py:38 -#: assets/serializers/asset/common.py:289 rbac/tree.py:35 +#: assets/serializers/asset/common.py:290 rbac/tree.py:35 msgid "Accounts" msgstr "账号管理" @@ -1487,26 +1487,27 @@ msgstr "自动代填" msgid "Protocols" msgstr "协议组" -#: assets/serializers/asset/common.py:144 +#: assets/serializers/asset/common.py:142 +#: assets/serializers/asset/common.py:292 +msgid "Auto info" +msgstr "自动化信息" + +#: assets/serializers/asset/common.py:145 msgid "Node path" msgstr "节点路径" -#: assets/serializers/asset/common.py:217 +#: assets/serializers/asset/common.py:218 msgid "Platform not exist" msgstr "平台不存在" -#: assets/serializers/asset/common.py:252 +#: assets/serializers/asset/common.py:253 msgid "port out of range (1-65535)" msgstr "端口超出范围 (1-65535)" -#: assets/serializers/asset/common.py:259 +#: assets/serializers/asset/common.py:260 msgid "Protocol is required: {}" msgstr "协议是必填的: {}" -#: assets/serializers/asset/common.py:291 -msgid "Auto info" -msgstr "自动化信息" - #: assets/serializers/asset/database.py:25 common/serializers/fields.py:100 #: tickets/serializers/ticket/common.py:58 #: xpack/plugins/cloud/serializers/account_attrs.py:56 @@ -1564,6 +1565,10 @@ msgstr "系统版本" msgid "OS arch" msgstr "系统架构" +#: assets/serializers/asset/host.py:28 +msgid "Info" +msgstr "信息" + #: assets/serializers/cagegory.py:9 msgid "Constraints" msgstr "约束" From b3851adfe788c9d94e16c345d43b857eeacbb52c Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 23 Feb 2023 19:35:10 +0800 Subject: [PATCH 19/21] perf: translate (#9730) Co-authored-by: feng <1304903146@qq.com> --- apps/accounts/serializers/automations/change_secret.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/accounts/serializers/automations/change_secret.py b/apps/accounts/serializers/automations/change_secret.py index cd597a805..eba6cd88d 100644 --- a/apps/accounts/serializers/automations/change_secret.py +++ b/apps/accounts/serializers/automations/change_secret.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy as _ from rest_framework import serializers from accounts.const import ( From 9b852f8b35a2ed0ea528683c9621ea0abe2e353a Mon Sep 17 00:00:00 2001 From: Bai Date: Thu, 23 Feb 2023 19:38:40 +0800 Subject: [PATCH 20/21] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E5=88=97=E8=A1=A8=E6=8E=92=E5=BA=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/rbac/api/role.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/rbac/api/role.py b/apps/rbac/api/role.py index bb74f1b1c..d59c42192 100644 --- a/apps/rbac/api/role.py +++ b/apps/rbac/api/role.py @@ -18,11 +18,11 @@ __all__ = [ class RoleViewSet(JMSModelViewSet): queryset = Role.objects.all() - ordering = ('-builtin', 'scope', 'name') serializer_classes = { 'default': RoleSerializer, 'users': RoleUserSerializer, } + ordering = ('-builtin', 'name') filterset_class = RoleFilter search_fields = ('name', 'scope', 'builtin') rbac_perms = { @@ -56,11 +56,15 @@ class RoleViewSet(JMSModelViewSet): return instance.permissions.set(clone.get_permissions()) - @staticmethod - def set_users_amount(queryset): + def filter_queryset(self, queryset): + queryset = super().filter_queryset(queryset) + queryset = queryset.order_by(*self.ordering) + return queryset + + def set_users_amount(self, queryset): """设置角色的用户绑定数量,以减少查询""" ids = [role.id for role in queryset] - queryset = Role.objects.filter(id__in=ids) + queryset = Role.objects.filter(id__in=ids).order_by(*self.ordering) org_id = current_org.id q = Q(role__scope=Role.Scope.system) | Q(role__scope=Role.Scope.org, org_id=org_id) role_bindings = RoleBinding.objects.filter(q).values_list('role_id').annotate(user_count=Count('user_id')) @@ -95,14 +99,16 @@ class SystemRoleViewSet(RoleViewSet): perm_model = SystemRole def get_queryset(self): - return super().get_queryset().filter(scope='system') + qs = super().get_queryset().filter(scope='system') + return qs class OrgRoleViewSet(RoleViewSet): perm_model = OrgRole def get_queryset(self): - return super().get_queryset().filter(scope='org') + qs = super().get_queryset().filter(scope='org') + return qs class BaseRolePermissionsViewSet(PermissionViewSet): From 05d40a525595dcf783f3c81c334acccb978b6ff8 Mon Sep 17 00:00:00 2001 From: Bai Date: Thu, 23 Feb 2023 19:56:28 +0800 Subject: [PATCH 21/21] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E5=88=97=E8=A1=A8=E5=88=9B=E5=BB=BA=E5=90=8C=E5=90=8D?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/serializers/platform.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/apps/assets/serializers/platform.py b/apps/assets/serializers/platform.py index 277c8388d..1e4172dc8 100644 --- a/apps/assets/serializers/platform.py +++ b/apps/assets/serializers/platform.py @@ -87,9 +87,6 @@ class PlatformProtocolsSerializer(serializers.ModelSerializer): class PlatformSerializer(WritableNestedModelSerializer): - name = serializers.CharField( - label=_("Name"), max_length=50, validators=[validators.validate_unicode_slug] - ) charset = LabeledChoiceField( choices=Platform.CharsetChoices.choices, label=_("Charset") )