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-12 00:32:51 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
364099933d6129df502534e4eb19606bcc8e06d5
36409993
1 parent
d58dedd2
add root folder for main folder
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
3 deletions
backend/api/migrations/0002_auto_20200611_1529.py
backend/api/models.py
backend/api/views.py
backend/api/migrations/0002_auto_20200611_1529.py
0 → 100644
View file @
3640999
# Generated by Django 3.0.6 on 2020-06-11 15:29
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'api'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'user'
,
name
=
'root_folder'
,
field
=
models
.
IntegerField
(
null
=
True
),
),
migrations
.
AlterField
(
model_name
=
'item'
,
name
=
'parent'
,
field
=
models
.
IntegerField
(
null
=
True
),
),
]
backend/api/models.py
View file @
3640999
...
...
@@ -8,7 +8,7 @@ class Item(models.Model):
file_type
=
models
.
CharField
(
max_length
=
100
,
null
=
True
)
# signed_url 생성을 위해 file type 세팅
path
=
models
.
TextField
()
#parent = models.ForeignKey('Item', on_delete=models.CASCADE, null=True) #related_name
parent
=
models
.
IntegerField
(
)
parent
=
models
.
IntegerField
(
null
=
True
)
# root 폴더의 경우 null임
user_id
=
models
.
IntegerField
()
size
=
models
.
IntegerField
()
is_deleted
=
models
.
BooleanField
(
default
=
False
)
...
...
@@ -37,6 +37,7 @@ class User(models.Model):
user_id
=
models
.
CharField
(
max_length
=
50
)
name
=
models
.
CharField
(
max_length
=
50
)
password
=
models
.
CharField
(
max_length
=
20
)
root_folder
=
models
.
IntegerField
(
null
=
True
)
total_size
=
models
.
IntegerField
()
current_size
=
models
.
IntegerField
()
created_time
=
models
.
DateTimeField
(
auto_now
=
True
)
...
...
backend/api/views.py
View file @
3640999
...
...
@@ -13,14 +13,15 @@ from rest_framework.response import Response
from
rest_framework.decorators
import
action
from
rest_framework.permissions
import
IsAuthenticated
,
AllowAny
from
api
.models
import
Item
,
SharedItem
,
User
from
api
.serializers
import
UserSerializer
,
GroupSerializer
,
ItemSerializer
from
.models
import
Item
,
SharedItem
,
User
from
.serializers
import
UserSerializer
,
GroupSerializer
,
ItemSerializer
from
rest_framework
import
status
from
annoying.functions
import
get_object_or_None
from
django.conf
import
settings
import
jwt
from
django.http
import
HttpResponse
,
JsonResponse
class
UserViewSet
(
viewsets
.
ModelViewSet
):
"""
API endpoint that allows users to be viewed or edited.
...
...
@@ -42,11 +43,15 @@ class UserViewSet(viewsets.ModelViewSet):
if
user
==
None
:
user
=
User
(
user_id
=
user_id
,
name
=
name
,
password
=
password
,
total_size
=
100000
,
current_size
=
0
)
user
.
save
()
root
=
Item
(
is_folder
=
True
,
name
=
"root"
,
file_type
=
"folder"
,
path
=
""
,
user_id
=
user
.
int_id
,
size
=
0
,
status
=
True
)
root
.
save
()
return
Response
({
'message'
:
'user created'
,
'int_id'
:
user
.
int_id
,
'user_id'
:
user
.
user_id
,
'name'
:
user
.
name
,
'root_folder'
:
root
.
item_id
,
'total_size'
:
user
.
total_size
,
'current_size'
:
user
.
current_size
,
'created_time'
:
user
.
created_time
...
...
Please
register
or
login
to post a comment