perf: 继续替换 spec

pull/9380/head
ibuler 2 years ago
parent 41154d3793
commit ef51e74b8e

@ -50,7 +50,7 @@ class BaseAccount(JMSOrgBaseModel):
return bool(self.username)
@property
def specific(self):
def spec_info(self):
data = {}
if self.secret_type != SecretType.SSH_KEY:
return data

@ -68,14 +68,14 @@ class BaseAccountSerializer(AuthValidateMixin, BulkOrgResourceModelSerializer):
fields_mini = ['id', 'name', 'username']
fields_small = fields_mini + [
'secret_type', 'secret', 'has_secret', 'passphrase',
'privileged', 'is_active', 'specific',
'privileged', 'is_active', 'spec_info',
]
fields_other = ['created_by', 'date_created', 'date_updated', 'comment']
fields = fields_small + fields_other
read_only_fields = [
'has_secret', 'specific',
'has_secret', 'spec_info',
'date_verified', 'created_by', 'date_created',
]
extra_kwargs = {
'specific': {'label': _('Specific')},
'spec_info': {'label': _('Spec info')},
}

@ -105,7 +105,7 @@ class JMSInventory:
'id': str(asset.id), 'name': asset.name, 'address': asset.address,
'type': asset.type, 'category': asset.category,
'protocol': asset.protocol, 'port': asset.port,
'specific': asset.spec,
'spec_info': asset.spec_info,
'protocols': [{'name': p.name, 'port': p.port} for p in protocols],
},
'jms_account': {

@ -4,13 +4,13 @@
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
from accounts.models import Account
from assets.const import Category, AllTypes
from assets.models import Node, Asset, Platform
from accounts.models import Account
from assets.serializers.asset.common import AssetProtocolsSerializer
from common.serializers.fields import ObjectRelatedField, LabeledChoiceField
from perms.serializers.permission import ActionChoicesField
from orgs.mixins.serializers import OrgResourceModelSerializerMixin
from perms.serializers.permission import ActionChoicesField
__all__ = [
'NodePermedSerializer', 'AssetPermedSerializer',
@ -32,7 +32,7 @@ class AssetPermedSerializer(OrgResourceModelSerializerMixin):
"id", "name", "address", 'domain', 'platform',
"comment", "org_id", "is_active",
]
fields = only_fields + ['protocols', 'category', 'type', 'specific'] + ['org_name']
fields = only_fields + ['protocols', 'category', 'type', 'spec_info'] + ['org_name']
read_only_fields = fields

@ -87,7 +87,7 @@ class WebAPP(object):
self.account = account
self.platform = platform
self.extra_data = self.asset.specific
self.extra_data = self.asset.spec_info
self._steps = list()
autofill_type = self.asset.spec_info.autofill
if autofill_type == "basic":
@ -105,24 +105,24 @@ class WebAPP(object):
def _default_custom_steps(self) -> list:
account = self.account
specific_property = self.asset.specific
spec_info = self.asset.spec_info
default_steps = [
Step({
"step": 1,
"value": account.username,
"target": specific_property.username_selector,
"target": spec_info.username_selector,
"command": "type"
}),
Step({
"step": 2,
"value": account.secret,
"target": specific_property.password_selector,
"target": spec_info.password_selector,
"command": "type"
}),
Step({
"step": 3,
"value": "",
"target": specific_property.submit_selector,
"target": spec_info.submit_selector,
"command": "click"
})
]

Loading…
Cancel
Save