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-11 00:37:33 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
6bfcd36e23c20af19e001d064b1711d1a080be81
6bfcd36e
2 parents
79b774ee
4480152e
Merge branch 'feature/folder' into 'develop'
Feature/folder See merge request
!8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
backend/api/views.py
backend/khudrive/urls.py
backend/api/views.py
View file @
6bfcd36
...
...
@@ -148,6 +148,40 @@ 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'
:
name
=
request
.
POST
.
get
(
'name'
,
''
함
)
#TODO: user_id 수정해야
item
=
Item
(
is_folder
=
True
,
name
=
name
,
file_type
=
"folder"
,
path
=
""
,
parent
=
pk
,
user_id
=
1
,
size
=
0
,
status
=
True
)
item
.
save
()
item
=
Item
.
objects
.
filter
(
item_id
=
item
.
item_id
)
item_data
=
serializers
.
serialize
(
"json"
,
item
)
json_item
=
json
.
loads
(
item_data
)
res
=
json_item
[
0
][
'fields'
]
res
[
'id'
]
=
json_item
[
0
][
'pk'
]
res
[
'inside_folder_list'
]
=
[]
res
[
'inside_file_list'
]
=
[]
return
Response
({
'data'
:
res
},
status
=
status
.
HTTP_200_OK
)
class
SharedItemViewSet
(
viewsets
.
ModelViewSet
):
...
...
backend/khudrive/urls.py
View file @
6bfcd36
...
...
@@ -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