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 22:38:34 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8a3875a62d3befa9f87173bde6ad4be67c08fec6
8a3875a6
1 parent
bb18bd85
children api added
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletions
backend/api/views.py
backend/khudrive/urls.py
backend/api/views.py
View file @
8a3875a
...
...
@@ -144,6 +144,30 @@ 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
,
*
args
,
**
kwargs
):
if
request
.
method
==
'GET'
:
parent_item
=
Item
.
objects
.
get
(
pk
=
pk
)
try
:
parent_item
=
get_object_or_404
(
Item
,
pk
=
pk
)
except
parent_item
.
DoesNotExist
:
return
Response
({
'Error'
:
'Folder does not exist.'
})
items
=
Item
.
objects
.
get
(
parent
=
parent_item
.
pk
)
return
Response
(
items
)
if
request
.
method
==
'POST'
:
data
=
JSONParser
()
.
parse
(
request
)
serializer
=
ItemSerializer
(
data
=
data
)
if
serializer
.
is_valid
():
serializer
.
save
()
return
Response
(
serializer
.
data
)
return
Response
(
serializer
.
errors
)
class
SharedItemViewSet
(
viewsets
.
ModelViewSet
):
...
...
@@ -181,4 +205,4 @@ class SharedItemViewSet(viewsets.ModelViewSet):
item
=
ItemViewSet
.
as_view
({
'delete'
:
'destroy'
,
})
\ No newline at end of file
})
...
...
backend/khudrive/urls.py
View file @
8a3875a
...
...
@@ -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'^children/$'
,
views
.
ItemViewSet
.
children
,
name
=
'children'
),
]
...
...
Please
register
or
login
to post a comment