mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-19 18:34:28 +00:00
@@ -29,9 +29,9 @@ class ProtocolForm(forms.Form):
|
|||||||
class AssetCreateForm(OrgModelForm):
|
class AssetCreateForm(OrgModelForm):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
if not self.data:
|
nodes_field = self.fields['nodes']
|
||||||
nodes_field = self.fields['nodes']
|
nodes_field.choices = ((n.id, n.full_value) for n in
|
||||||
nodes_field._queryset = Node.get_queryset()
|
Node.get_queryset())
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Asset
|
model = Asset
|
||||||
|
@@ -41,6 +41,9 @@ class AssetPermissionForm(OrgModelForm):
|
|||||||
users_field = self.fields.get('users')
|
users_field = self.fields.get('users')
|
||||||
users_field.queryset = current_org.get_org_users()
|
users_field.queryset = current_org.get_org_users()
|
||||||
|
|
||||||
|
nodes_field = self.fields['nodes']
|
||||||
|
nodes_field.choices = ((n.id, n.full_value) for n in Node.get_queryset())
|
||||||
|
|
||||||
# 前端渲染优化, 防止过多资产
|
# 前端渲染优化, 防止过多资产
|
||||||
if not self.data:
|
if not self.data:
|
||||||
instance = kwargs.get('instance')
|
instance = kwargs.get('instance')
|
||||||
@@ -49,8 +52,6 @@ class AssetPermissionForm(OrgModelForm):
|
|||||||
assets_field.queryset = instance.assets.all()
|
assets_field.queryset = instance.assets.all()
|
||||||
else:
|
else:
|
||||||
assets_field.queryset = Asset.objects.none()
|
assets_field.queryset = Asset.objects.none()
|
||||||
nodes_field = self.fields['nodes']
|
|
||||||
nodes_field._queryset = Node.get_queryset()
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = AssetPermission
|
model = AssetPermission
|
||||||
|
Reference in New Issue
Block a user