Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
5f96f8c2
Commit
5f96f8c2
authored
Oct 10, 2019
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 优化节点删除 API,添加删除失败原因
parent
7e7583e4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
2 deletions
+17
-2
node.py
apps/assets/api/node.py
+11
-1
node.py
apps/assets/models/node.py
+6
-1
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+0
-0
No files found.
apps/assets/api/node.py
View file @
5f96f8c2
...
...
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
rest_framework
import
generics
from
rest_framework
import
generics
,
status
from
rest_framework.serializers
import
ValidationError
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
...
...
@@ -59,6 +59,16 @@ class NodeViewSet(OrgModelViewSet):
raise
ValidationError
({
"error"
:
msg
})
return
super
()
.
perform_update
(
serializer
)
def
destroy
(
self
,
request
,
*
args
,
**
kwargs
):
node
=
self
.
get_object
()
if
node
.
has_children_or_contains_assets
():
msg
=
_
(
"Deletion failed "
"and the node contains children or assets"
)
return
Response
(
data
=
{
'msg'
:
msg
},
status
=
status
.
HTTP_500_INTERNAL_SERVER_ERROR
)
return
super
()
.
destroy
(
request
,
*
args
,
**
kwargs
)
class
NodeListAsTreeApi
(
generics
.
ListAPIView
):
"""
...
...
apps/assets/models/node.py
View file @
5f96f8c2
...
...
@@ -470,8 +470,13 @@ class Node(OrgModelMixin, SomeNodesMixin, TreeMixin, FamilyMixin, FullValueMixin
tree_node
=
TreeNode
(
**
data
)
return
tree_node
def
delete
(
self
,
using
=
None
,
keep_parents
=
False
):
def
has_children_or_contains_assets
(
self
):
if
self
.
children
or
self
.
get_assets
():
return
True
return
False
def
delete
(
self
,
using
=
None
,
keep_parents
=
False
):
if
self
.
has_children_or_contains_assets
():
return
return
super
()
.
delete
(
using
=
using
,
keep_parents
=
keep_parents
)
...
...
apps/locale/zh/LC_MESSAGES/django.mo
View file @
5f96f8c2
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
5f96f8c2
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment