From cbf91e4c29cbe79537809fc36531d0382dbd33c0 Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Thu, 15 Dec 2022 11:59:14 +0800 Subject: [PATCH 1/2] perf: ticket help text --- apps/jumpserver/api.py | 2 +- apps/tickets/serializers/ticket/apply_asset.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/jumpserver/api.py b/apps/jumpserver/api.py index b0b31f4c9..284ad429d 100644 --- a/apps/jumpserver/api.py +++ b/apps/jumpserver/api.py @@ -232,7 +232,7 @@ class DatesLoginMetricMixin: result = list(result) for i in result: tp = i['type'] - i['label'] = all_types_dict[tp] + i['label'] = all_types_dict.get(tp, tp) return result def get_dates_login_times_assets(self): diff --git a/apps/tickets/serializers/ticket/apply_asset.py b/apps/tickets/serializers/ticket/apply_asset.py index a0938cd99..8bf7b8563 100644 --- a/apps/tickets/serializers/ticket/apply_asset.py +++ b/apps/tickets/serializers/ticket/apply_asset.py @@ -13,10 +13,18 @@ __all__ = ['ApplyAssetSerializer', 'ApproveAssetSerializer'] asset_or_node_help_text = _("Select at least one asset or node") +apply_help_text = _('Support fuzzy search, and display up to 10 items') + class ApplyAssetSerializer(BaseApplyAssetSerializer, TicketApplySerializer): - apply_assets = ObjectRelatedField(queryset=Asset.objects, many=True, required=False, label=_('Apply assets')) - apply_nodes = ObjectRelatedField(queryset=Node.objects, many=True, required=False, label=_('Apply nodes')) + apply_assets = ObjectRelatedField( + queryset=Asset.objects, many=True, required=False, + label=_('Apply assets'), help_text=apply_help_text + ) + apply_nodes = ObjectRelatedField( + queryset=Node.objects, many=True, required=False, + label=_('Apply nodes'), help_text=apply_help_text + ) apply_actions = ActionChoicesField(required=False, allow_null=True, label=_("Apply actions")) permission_model = AssetPermission From 840ca02223088bbe63fa81797c49bf760f4e663b Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Thu, 15 Dec 2022 15:21:51 +0800 Subject: [PATCH 2/2] perf: del redundant macos --- .../migrations/0114_remove_redundant_macos.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 apps/assets/migrations/0114_remove_redundant_macos.py diff --git a/apps/assets/migrations/0114_remove_redundant_macos.py b/apps/assets/migrations/0114_remove_redundant_macos.py new file mode 100644 index 000000000..1d8183e12 --- /dev/null +++ b/apps/assets/migrations/0114_remove_redundant_macos.py @@ -0,0 +1,29 @@ +# Generated by Django 3.2.14 on 2022-12-15 07:08 + +from django.db import migrations + + +def migrate_del_macos(apps, schema_editor): + db_alias = schema_editor.connection.alias + asset_model = apps.get_model('assets', 'Asset') + platform_model = apps.get_model('assets', 'Platform') + old_macos = platform_model.objects.using(db_alias).get( + name='MacOS', type='macos' + ) + new_macos = platform_model.objects.using(db_alias).get( + name='macOS', type='unix' + ) + asset_model.objects.using(db_alias).filter( + platform=old_macos).update(platform=new_macos) + + platform_model.objects.using(db_alias).filter(id=old_macos.id).delete() + + +class Migration(migrations.Migration): + dependencies = [ + ('assets', '0113_auto_20221122_2015'), + ] + + operations = [ + migrations.RunPython(migrate_del_macos), + ]