mirror of https://github.com/jumpserver/jumpserver
fix: 修复remote app没有返回asset的bug
parent
7d7da9bf98
commit
dba416f5eb
|
@ -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()
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue