提交 f6c24f80 编写于 作者: B Bai 提交者: Jiangjie.Bai

perf(application): 修改DoaminAPI返回application数量;修改Application数据库datbase字段required=False

上级 c74c9f51
......@@ -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()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册