mirror of https://github.com/jumpserver/jumpserver
[update] 修改Node无法被删除的bug
parent
bab4326aeb
commit
6f570bcbf1
|
@ -9,13 +9,18 @@ from django.utils.translation import ugettext_lazy as _
|
||||||
from django.utils.translation import ugettext
|
from django.utils.translation import ugettext
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
|
|
||||||
from orgs.mixins import OrgModelMixin
|
from orgs.mixins import OrgModelMixin, OrgManager
|
||||||
from orgs.utils import set_current_org, get_current_org
|
from orgs.utils import set_current_org, get_current_org
|
||||||
from orgs.models import Organization
|
from orgs.models import Organization
|
||||||
|
|
||||||
__all__ = ['Node']
|
__all__ = ['Node']
|
||||||
|
|
||||||
|
|
||||||
|
class NodeQuerySet(models.QuerySet):
|
||||||
|
def delete(self):
|
||||||
|
raise PermissionError("Bulk delete node deny")
|
||||||
|
|
||||||
|
|
||||||
class FamilyMixin:
|
class FamilyMixin:
|
||||||
_parents = None
|
_parents = None
|
||||||
_children = None
|
_children = None
|
||||||
|
@ -242,6 +247,7 @@ class Node(OrgModelMixin, FamilyMixin, FullValueMixin, AssetsAmountMixin):
|
||||||
child_mark = models.IntegerField(default=0)
|
child_mark = models.IntegerField(default=0)
|
||||||
date_create = models.DateTimeField(auto_now_add=True)
|
date_create = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
|
objects = OrgManager.from_queryset(NodeQuerySet)()
|
||||||
is_node = True
|
is_node = True
|
||||||
_parents = None
|
_parents = None
|
||||||
|
|
||||||
|
@ -391,6 +397,7 @@ class Node(OrgModelMixin, FamilyMixin, FullValueMixin, AssetsAmountMixin):
|
||||||
"name": self.name,
|
"name": self.name,
|
||||||
"value": self.value,
|
"value": self.value,
|
||||||
"key": self.key,
|
"key": self.key,
|
||||||
|
"assets_amount": self.assets_amount,
|
||||||
},
|
},
|
||||||
'type': 'node'
|
'type': 'node'
|
||||||
}
|
}
|
||||||
|
@ -398,6 +405,11 @@ class Node(OrgModelMixin, FamilyMixin, FullValueMixin, AssetsAmountMixin):
|
||||||
tree_node = TreeNode(**data)
|
tree_node = TreeNode(**data)
|
||||||
return tree_node
|
return tree_node
|
||||||
|
|
||||||
|
def delete(self, using=None, keep_parents=False):
|
||||||
|
if self.children or self.assets.get_assets():
|
||||||
|
return
|
||||||
|
return super().delete(using=using, keep_parents=keep_parents)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_queryset(cls):
|
def get_queryset(cls):
|
||||||
from ..utils import NodeUtil
|
from ..utils import NodeUtil
|
||||||
|
|
|
@ -301,10 +301,10 @@ LOGGING = {
|
||||||
'handlers': ['gunicorn_console', 'gunicorn_file'],
|
'handlers': ['gunicorn_console', 'gunicorn_file'],
|
||||||
'level': 'INFO',
|
'level': 'INFO',
|
||||||
},
|
},
|
||||||
'django.db': {
|
# 'django.db': {
|
||||||
'handlers': ['console', 'file'],
|
# 'handlers': ['console', 'file'],
|
||||||
'level': 'DEBUG'
|
# 'level': 'DEBUG'
|
||||||
}
|
# }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue