Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-CloudComputing
/
C_Team_KhuDrive
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
김재형
2020-06-14 23:12:59 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
98fd313dcc06d4848fdfb3f0aecca151d92f3720
98fd313d
1 parent
4a7e79d0
Implement rename api
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
backend/api/views.py
backend/api/views.py
View file @
98fd313
...
...
@@ -187,12 +187,27 @@ class ItemViewSet(viewsets.ViewSet):
if
request
.
method
==
'POST'
:
parent_id
=
request
.
POST
.
get
(
'parent'
,
''
)
name
=
request
.
POST
.
get
(
'name'
,
''
)
parent
=
get_object_or_None
(
Item
,
item_id
=
parent_id
)
if
parent
!=
None
and
parent
.
is_folder
==
True
:
child
=
get_object_or_None
(
Item
,
item_id
=
pk
)
if
child
==
None
:
return
Response
({
'message'
:
'item is not existed.'
},
status
=
status
.
HTTP_204_NO_CONTENT
)
if
parent_id
!=
''
:
parent
=
get_object_or_None
(
Item
,
item_id
=
parent_id
)
if
parent
==
None
:
return
Response
({
'message'
:
'parent is not existed.'
},
status
=
status
.
HTTP_200_OK
)
if
parent
.
is_folder
==
False
:
return
Response
({
'message'
:
'parent is not folder.'
},
status
=
status
.
HTTP_200_OK
)
if
parent
!=
None
and
parent
.
is_folder
==
True
:
child
.
parent
=
parent_id
else
:
parent_id
=
child
.
parent
if
name
!=
''
:
child
.
name
=
name
;
child
.
save
()
child
=
Item
.
objects
.
filter
(
item_id
=
pk
)
child_data
=
serializers
.
serialize
(
"json"
,
child
)
...
...
@@ -203,12 +218,8 @@ class ItemViewSet(viewsets.ViewSet):
parent_data
=
serializers
.
serialize
(
"json"
,
parent
)
json_parent
=
json
.
loads
(
parent_data
)[
0
][
'fields'
]
res
[
'parentInfo'
]
=
json_parent
return
Response
({
'data'
:
res
},
status
=
status
.
HTTP_200_OK
)
if
parent
==
None
:
return
Response
({
'message'
:
'parent is not existed.'
},
status
=
status
.
HTTP_200_OK
)
if
parent
.
is_folder
==
False
:
return
Response
({
'message'
:
'parent is not folder.'
},
status
=
status
.
HTTP_200_OK
)
return
Response
({
'message'
:
'item is not existed.'
},
status
=
status
.
HTTP_204_NO_CONTENT
)
@action
(
methods
=
[
'POST'
],
detail
=
True
,
permission_classes
=
[
AllowAny
],
url_path
=
'copy'
,
url_name
=
'copy'
)
def
copy
(
self
,
request
,
pk
):
...
...
Please
register
or
login
to post a comment