mirror of https://github.com/jumpserver/jumpserver
perf(application): 修改DoaminAPI返回application数量;修改Application数据库datbase字段required=False
parent
c74c9f51f0
commit
f6c24f809c
|
@ -13,7 +13,7 @@ class DBAttrsSerializer(serializers.Serializer):
|
|||
host = serializers.CharField(max_length=128, label=_('Host'))
|
||||
port = serializers.IntegerField(label=_('Port'))
|
||||
database = serializers.CharField(
|
||||
max_length=128, allow_blank=True, allow_null=True, label=_('Database')
|
||||
max_length=128, required=False, allow_blank=True, allow_null=True, label=_('Database')
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ from .base import AuthSerializerMixin
|
|||
|
||||
class DomainSerializer(BulkOrgResourceModelSerializer):
|
||||
asset_count = serializers.SerializerMethodField()
|
||||
application_count = serializers.SerializerMethodField()
|
||||
gateway_count = serializers.SerializerMethodField()
|
||||
|
||||
class Meta:
|
||||
|
@ -20,7 +21,7 @@ class DomainSerializer(BulkOrgResourceModelSerializer):
|
|||
'comment', 'date_created'
|
||||
]
|
||||
fields_m2m = [
|
||||
'asset_count', 'assets', 'gateway_count',
|
||||
'asset_count', 'assets', 'application_count', 'gateway_count',
|
||||
]
|
||||
fields = fields_small + fields_m2m
|
||||
read_only_fields = ('asset_count', 'gateway_count', 'date_created')
|
||||
|
@ -33,6 +34,10 @@ class DomainSerializer(BulkOrgResourceModelSerializer):
|
|||
def get_asset_count(obj):
|
||||
return obj.assets.count()
|
||||
|
||||
@staticmethod
|
||||
def get_application_count(obj):
|
||||
return obj.applications.count()
|
||||
|
||||
@staticmethod
|
||||
def get_gateway_count(obj):
|
||||
return obj.gateway_set.all().count()
|
||||
|
|
Loading…
Reference in New Issue