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-10 23:05:37 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
17ecff4d91bde256b6e32d1961d97b6527c5ec7b
17ecff4d
1 parent
79b774ee
implement children get api
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
0 deletions
backend/api/views.py
backend/khudrive/urls.py
backend/api/views.py
View file @
17ecff4
...
...
@@ -148,6 +148,36 @@ class ItemViewSet(viewsets.ViewSet):
# action is not set return default permission_classes
return
[
permission
()
for
permission
in
self
.
permission_classes
]
# url: items/{key}/children/
@action
(
methods
=
[
'GET'
,
'POST'
],
detail
=
True
,
permission_classes
=
[
AllowAny
],
url_path
=
'children'
,
url_name
=
'children'
)
def
children
(
self
,
request
,
pk
):
if
request
.
method
==
'GET'
:
children
=
Item
.
objects
.
filter
(
parent
=
pk
)
children_data
=
serializers
.
serialize
(
"json"
,
children
)
json_children
=
json
.
loads
(
children_data
)
parent
=
Item
.
objects
.
filter
(
item_id
=
pk
)
#item
parent_data
=
serializers
.
serialize
(
"json"
,
parent
)
json_parent
=
json
.
loads
(
parent_data
)[
0
][
'fields'
]
res
=
json_parent
res
[
'id'
]
=
pk
children_list
=
[]
for
i
in
json_children
:
t
=
i
[
'fields'
]
t
[
'id'
]
=
i
[
'pk'
]
children_list
.
append
(
t
)
res
[
'list'
]
=
children_list
return
Response
({
'data'
:
res
},
status
=
status
.
HTTP_200_OK
)
if
request
.
method
==
'POST'
:
print
(
"post"
)
#
# data = JSONParser().parse(request)
# serializer = ItemSerializer(data=data)
# if serializer.is_valid():
# serializer.save()
# return Response(serializer.data)
return
Response
({
'message'
:
'post is not existed.'
},
status
=
status
.
HTTP_204_NO_CONTENT
)
class
SharedItemViewSet
(
viewsets
.
ModelViewSet
):
...
...
backend/khudrive/urls.py
View file @
17ecff4
...
...
@@ -33,5 +33,6 @@ urlpatterns = [
url
(
r'^<int:pk>/share/$'
,
views
.
SharedItemViewSet
.
share
,
name
=
'share'
),
url
(
r'^<int:pk>/move/$'
,
views
.
ItemViewSet
.
move
,
name
=
'move'
),
url
(
r'^<int:pk>/copy/$'
,
views
.
ItemViewSet
.
copy
,
name
=
'copy'
),
url
(
r'^<int:pk>/children/$'
,
views
.
ItemViewSet
.
children
,
name
=
'copy'
),
]
...
...
Please
register
or
login
to post a comment