perf: 关闭SFTP后,luna界面不显示相应选项 (#10186)

* perf: 关闭SFTP后,luna界面不显示相应选项

* perf: 修改默认值

* perf: 增加资产协议冗余字段,减少关联查询

* perf: 修改

* perf: 优化

* perf: 精简

* perf: 删掉空格

* perf: 修改继承类
This commit is contained in:
jiangweidong
2023-04-13 17:26:24 +08:00
committed by GitHub
parent 1aadb760f4
commit e12b832992
3 changed files with 22 additions and 3 deletions

View File

@@ -94,6 +94,20 @@ class Protocol(models.Model):
def __str__(self):
return '{}/{}'.format(self.name, self.port)
@lazyproperty
def asset_platform_protocol(self):
protocols = self.asset.platform.protocols.values('name', 'public', 'setting')
protocols = list(filter(lambda p: p['name'] == self.name, protocols))
return protocols[0] if len(protocols) > 0 else {}
@property
def setting(self):
return self.asset_platform_protocol.get('setting', {})
@property
def public(self):
return self.asset_platform_protocol.get('public', True)
class Asset(NodesRelationMixin, AbsConnectivity, JMSOrgBaseModel):
Category = const.Category