From dba416f5eb11cc643c84af9deb0cd426ca07b1b3 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 17 Aug 2021 11:06:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dremote=20app=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E8=BF=94=E5=9B=9Easset=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/applications/api/account.py | 4 ++-- .../serializers/attrs/application_category/remote_app.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/applications/api/account.py b/apps/applications/api/account.py index 8071125b2..279ac926c 100644 --- a/apps/applications/api/account.py +++ b/apps/applications/api/account.py @@ -31,11 +31,11 @@ class ApplicationAccountViewSet(JMSModelViewSet): filterset_class = AccountFilterSet filterset_fields = ['username', 'app_name', 'type', 'category'] serializer_class = serializers.ApplicationAccountSerializer - http_method_names = ['get', 'put', 'patch', 'options'] def get_queryset(self): - queryset = ApplicationPermission.objects.exclude(system_users__isnull=True) \ + queryset = ApplicationPermission.objects\ + .exclude(system_users__isnull=True) \ .exclude(applications__isnull=True) \ .annotate(uid=Concat( 'applications', Value('_'), 'system_users', output_field=CharField() diff --git a/apps/applications/serializers/attrs/application_category/remote_app.py b/apps/applications/serializers/attrs/application_category/remote_app.py index fd5fa54f3..c50fd9364 100644 --- a/apps/applications/serializers/attrs/application_category/remote_app.py +++ b/apps/applications/serializers/attrs/application_category/remote_app.py @@ -14,7 +14,7 @@ logger = get_logger(__file__) __all__ = ['RemoteAppSerializer'] -class AssetCharPrimaryKeyRelatedField(serializers.PrimaryKeyRelatedField): +class ExistAssetPrimaryKeyRelatedField(serializers.PrimaryKeyRelatedField): def to_internal_value(self, data): instance = super().to_internal_value(data) @@ -26,14 +26,14 @@ class AssetCharPrimaryKeyRelatedField(serializers.PrimaryKeyRelatedField): return self.pk_field.to_representation(_id) # 解决删除资产后,远程应用更新页面会显示资产ID的问题 asset = get_object_or_none(Asset, id=_id) - if asset: + if not asset: return None return _id class RemoteAppSerializer(serializers.Serializer): asset_info = serializers.SerializerMethodField() - asset = AssetCharPrimaryKeyRelatedField( + asset = ExistAssetPrimaryKeyRelatedField( queryset=Asset.objects, required=False, label=_("Asset"), allow_null=True ) path = serializers.CharField(