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(