Merge remote-tracking branch 'origin/develop' into feature/frontend
Showing
18 changed files
with
191 additions
and
15 deletions
backend/api/admin.py
0 → 100644
backend/api/migrations/0001_initial.py
0 → 100644
1 | +# Generated by Django 3.0.6 on 2020-06-11 14:54 | ||
2 | + | ||
3 | +from django.db import migrations, models | ||
4 | + | ||
5 | + | ||
6 | +class Migration(migrations.Migration): | ||
7 | + | ||
8 | + initial = True | ||
9 | + | ||
10 | + dependencies = [ | ||
11 | + ] | ||
12 | + | ||
13 | + operations = [ | ||
14 | + migrations.CreateModel( | ||
15 | + name='Item', | ||
16 | + fields=[ | ||
17 | + ('item_id', models.AutoField(primary_key=True, serialize=False)), | ||
18 | + ('is_folder', models.BooleanField(default=False)), | ||
19 | + ('name', models.CharField(max_length=50)), | ||
20 | + ('file_type', models.CharField(max_length=100, null=True)), | ||
21 | + ('path', models.TextField()), | ||
22 | + ('parent', models.IntegerField()), | ||
23 | + ('user_id', models.IntegerField()), | ||
24 | + ('size', models.IntegerField()), | ||
25 | + ('is_deleted', models.BooleanField(default=False)), | ||
26 | + ('created_time', models.DateTimeField(auto_now=True)), | ||
27 | + ('updated_time', models.DateTimeField(null=True)), | ||
28 | + ('status', models.BooleanField()), | ||
29 | + ], | ||
30 | + options={ | ||
31 | + 'ordering': ['item_id'], | ||
32 | + }, | ||
33 | + ), | ||
34 | + migrations.CreateModel( | ||
35 | + name='SharedItem', | ||
36 | + fields=[ | ||
37 | + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
38 | + ('item_id', models.IntegerField()), | ||
39 | + ('expires', models.DateTimeField()), | ||
40 | + ('password', models.CharField(max_length=20)), | ||
41 | + ('created_time', models.DateTimeField(auto_now=True)), | ||
42 | + ], | ||
43 | + options={ | ||
44 | + 'ordering': ['item_id'], | ||
45 | + }, | ||
46 | + ), | ||
47 | + migrations.CreateModel( | ||
48 | + name='User', | ||
49 | + fields=[ | ||
50 | + ('int_id', models.AutoField(primary_key=True, serialize=False)), | ||
51 | + ('user_id', models.CharField(max_length=50)), | ||
52 | + ('name', models.CharField(max_length=50)), | ||
53 | + ('password', models.CharField(max_length=20)), | ||
54 | + ('total_size', models.IntegerField()), | ||
55 | + ('current_size', models.IntegerField()), | ||
56 | + ('created_time', models.DateTimeField(auto_now=True)), | ||
57 | + ], | ||
58 | + options={ | ||
59 | + 'ordering': ['int_id'], | ||
60 | + }, | ||
61 | + ), | ||
62 | + ] |
1 | +# Generated by Django 3.0.6 on 2020-06-11 15:29 | ||
2 | + | ||
3 | +from django.db import migrations, models | ||
4 | + | ||
5 | + | ||
6 | +class Migration(migrations.Migration): | ||
7 | + | ||
8 | + dependencies = [ | ||
9 | + ('api', '0001_initial'), | ||
10 | + ] | ||
11 | + | ||
12 | + operations = [ | ||
13 | + migrations.AddField( | ||
14 | + model_name='user', | ||
15 | + name='root_folder', | ||
16 | + field=models.IntegerField(null=True), | ||
17 | + ), | ||
18 | + migrations.AlterField( | ||
19 | + model_name='item', | ||
20 | + name='parent', | ||
21 | + field=models.IntegerField(null=True), | ||
22 | + ), | ||
23 | + ] |
backend/api/models.py
0 → 100644
1 | +from django.db import models | ||
2 | + | ||
3 | +# Create your models here. | ||
4 | +class Item(models.Model): | ||
5 | + item_id = models.AutoField(primary_key = True) | ||
6 | + is_folder = models.BooleanField(default = False) | ||
7 | + name = models.CharField(max_length = 50) | ||
8 | + file_type = models.CharField(max_length=100, null=True) # signed_url 생성을 위해 file type 세팅 | ||
9 | + path = models.TextField() | ||
10 | + #parent = models.ForeignKey('Item', on_delete=models.CASCADE, null=True) #related_name | ||
11 | + parent = models.IntegerField(null=True) # root 폴더의 경우 null임 | ||
12 | + user_id = models.IntegerField() | ||
13 | + size = models.IntegerField() | ||
14 | + is_deleted = models.BooleanField(default = False) | ||
15 | + created_time = models.DateTimeField(auto_now=True) | ||
16 | + updated_time = models.DateTimeField(null=True) | ||
17 | + status = models.BooleanField() | ||
18 | + | ||
19 | + #file = models.FileField(upload_to = \path) | ||
20 | + | ||
21 | + class Meta: | ||
22 | + ordering = ['item_id'] | ||
23 | + | ||
24 | + | ||
25 | +class SharedItem(models.Model): | ||
26 | + item_id = models.IntegerField() | ||
27 | + #file_id? | ||
28 | + expires = models.DateTimeField() | ||
29 | + password = models.CharField(max_length = 20) | ||
30 | + created_time = models.DateTimeField(auto_now=True) | ||
31 | + class Meta: | ||
32 | + ordering = ['item_id'] | ||
33 | + | ||
34 | + | ||
35 | +class User(models.Model): | ||
36 | + int_id = models.AutoField(primary_key = True) | ||
37 | + user_id = models.CharField(max_length = 50) | ||
38 | + name = models.CharField(max_length = 50) | ||
39 | + password = models.CharField(max_length = 20) | ||
40 | + root_folder = models.IntegerField(null=True) | ||
41 | + total_size = models.IntegerField() | ||
42 | + current_size = models.IntegerField() | ||
43 | + created_time = models.DateTimeField(auto_now=True) | ||
44 | + class Meta: | ||
45 | + ordering = ['int_id'] |
backend/api/serializers.py
0 → 100644
1 | +from django.contrib.auth.models import Group | ||
2 | +from rest_framework import serializers | ||
3 | +from .models import Item, SharedItem,User | ||
4 | + | ||
5 | + | ||
6 | +class UserSerializer(serializers.HyperlinkedModelSerializer): | ||
7 | + class Meta: | ||
8 | + model = User | ||
9 | + fields = '__all__' | ||
10 | + | ||
11 | +class GroupSerializer(serializers.HyperlinkedModelSerializer): | ||
12 | + class Meta: | ||
13 | + model = Group | ||
14 | + fields = ['url', 'name'] | ||
15 | + | ||
16 | +class ItemSerializer(serializers.ModelSerializer): | ||
17 | + class Meta: | ||
18 | + model = Item | ||
19 | + fields = '__all__' | ||
20 | + |
backend/api/views.py
0 → 100644
This diff is collapsed. Click to expand it.
backend/khudrive/api/admin.py
deleted
100644 → 0
backend/khudrive/api/models.py
deleted
100644 → 0
backend/khudrive/api/views.py
deleted
100644 → 0
1 | """ | 1 | """ |
2 | Django settings for khudrive project. | 2 | Django settings for khudrive project. |
3 | 3 | ||
4 | -Generated by 'django-admin startproject' using Django 3.0.6. | 4 | +Generated by 'django-admin startproject' using Django 3.0.7. |
5 | 5 | ||
6 | For more information on this file, see | 6 | For more information on this file, see |
7 | https://docs.djangoproject.com/en/3.0/topics/settings/ | 7 | https://docs.djangoproject.com/en/3.0/topics/settings/ |
... | @@ -20,7 +20,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ... | @@ -20,7 +20,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
20 | # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ | 20 | # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ |
21 | 21 | ||
22 | # SECURITY WARNING: keep the secret key used in production secret! | 22 | # SECURITY WARNING: keep the secret key used in production secret! |
23 | -SECRET_KEY = '3b=a99pdbz*48$9$kh@h3tkb*9w-m3vtf8ngyymdzwpl5$emwn' | 23 | +SECRET_KEY = ')i0_(*4t7k3=rcqp*_i0u((9zbk8q(2(3tk(%$woji-e-37=o*' |
24 | 24 | ||
25 | # SECURITY WARNING: don't run with debug turned on in production! | 25 | # SECURITY WARNING: don't run with debug turned on in production! |
26 | DEBUG = True | 26 | DEBUG = True |
... | @@ -38,6 +38,7 @@ INSTALLED_APPS = [ | ... | @@ -38,6 +38,7 @@ INSTALLED_APPS = [ |
38 | 'django.contrib.messages', | 38 | 'django.contrib.messages', |
39 | 'django.contrib.staticfiles', | 39 | 'django.contrib.staticfiles', |
40 | 'rest_framework', | 40 | 'rest_framework', |
41 | + 'api.apps.ApiConfig', | ||
41 | ] | 42 | ] |
42 | 43 | ||
43 | MIDDLEWARE = [ | 44 | MIDDLEWARE = [ |
... | @@ -73,11 +74,18 @@ WSGI_APPLICATION = 'khudrive.wsgi.application' | ... | @@ -73,11 +74,18 @@ WSGI_APPLICATION = 'khudrive.wsgi.application' |
73 | 74 | ||
74 | # Database | 75 | # Database |
75 | # https://docs.djangoproject.com/en/3.0/ref/settings/#databases | 76 | # https://docs.djangoproject.com/en/3.0/ref/settings/#databases |
76 | - | ||
77 | DATABASES = { | 77 | DATABASES = { |
78 | + # 'default': { | ||
79 | + # 'ENGINE': 'django.db.backends.sqlite3', | ||
80 | + # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | ||
81 | + # } | ||
78 | 'default': { | 82 | 'default': { |
79 | - 'ENGINE': 'django.db.backends.sqlite3', | 83 | + 'ENGINE': 'django.db.backends.postgresql', |
80 | - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | 84 | + 'NAME': 'khuDrive', |
85 | + 'USER': 'jooheekwon', | ||
86 | + 'PASSWORD': '', | ||
87 | + 'HOST': 'localhost', | ||
88 | + 'PORT': '', | ||
81 | } | 89 | } |
82 | } | 90 | } |
83 | 91 | ... | ... |
... | @@ -13,9 +13,28 @@ Including another URLconf | ... | @@ -13,9 +13,28 @@ Including another URLconf |
13 | 1. Import the include() function: from django.urls import include, path | 13 | 1. Import the include() function: from django.urls import include, path |
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) | 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) |
15 | """ | 15 | """ |
16 | +from django.urls import include, path | ||
17 | +from rest_framework import routers | ||
16 | from django.contrib import admin | 18 | from django.contrib import admin |
17 | -from django.urls import path | 19 | +from api import views |
20 | +from django.conf.urls import url | ||
18 | 21 | ||
22 | +router = routers.DefaultRouter() | ||
23 | +router.register(r'users', views.UserViewSet) | ||
24 | +router.register(r'items', views.ItemViewSet) | ||
25 | +router.register(r'items', views.SharedItemViewSet) | ||
26 | + | ||
27 | +# Wire up our API using automatic URL routing. | ||
28 | +# Additionally, we include login URLs for the browsable API. | ||
19 | urlpatterns = [ | 29 | urlpatterns = [ |
20 | path('admin/', admin.site.urls), | 30 | path('admin/', admin.site.urls), |
31 | + path('', include(router.urls)), | ||
32 | + url(r'^search/$', views.ItemViewSet.search, name='search'), | ||
33 | + url(r'^<int:pk>/share/$', views.SharedItemViewSet.share, name='share'), | ||
34 | + url(r'^<int:pk>/move/$', views.ItemViewSet.move, name='move'), | ||
35 | + url(r'^<int:pk>/copy/$', views.ItemViewSet.copy, name='copy'), | ||
36 | + url(r'^<int:pk>/children/$', views.ItemViewSet.children, name='copy'), | ||
37 | + url(r'^signup/$', views.UserViewSet.signup, name='signup'), | ||
38 | + url(r'^login/$', views.UserViewSet.login, name='login'), | ||
39 | + | ||
21 | ] | 40 | ] | ... | ... |
-
Please register or login to post a comment