Merge remote-tracking branch 'origin/develop' into feature/frontend
Showing
18 changed files
with
367 additions
and
191 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 | -ASGI config for khudrive project. | 2 | +ASGI config for khudrive project. |
3 | - | 3 | + |
4 | -It exposes the ASGI callable as a module-level variable named ``application``. | 4 | +It exposes the ASGI callable as a module-level variable named ``application``. |
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/howto/deployment/asgi/ | 7 | +https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ |
8 | -""" | 8 | +""" |
9 | - | 9 | + |
10 | -import os | 10 | +import os |
11 | - | 11 | + |
12 | -from django.core.asgi import get_asgi_application | 12 | +from django.core.asgi import get_asgi_application |
13 | - | 13 | + |
14 | -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'khudrive.settings') | 14 | +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'khudrive.settings') |
15 | - | 15 | + |
16 | -application = get_asgi_application() | 16 | +application = get_asgi_application() | ... | ... |
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/ |
8 | - | 8 | + |
9 | -For the full list of settings and their values, see | 9 | +For the full list of settings and their values, see |
10 | -https://docs.djangoproject.com/en/3.0/ref/settings/ | 10 | +https://docs.djangoproject.com/en/3.0/ref/settings/ |
11 | -""" | 11 | +""" |
12 | - | 12 | + |
13 | -import os | 13 | +import os |
14 | - | 14 | + |
15 | -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | 15 | +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) |
16 | -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | 16 | +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
17 | - | 17 | + |
18 | - | 18 | + |
19 | -# Quick-start development settings - unsuitable for production | 19 | +# Quick-start development settings - unsuitable for production |
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 |
27 | - | 27 | + |
28 | -ALLOWED_HOSTS = [] | 28 | +ALLOWED_HOSTS = [] |
29 | - | 29 | + |
30 | - | 30 | + |
31 | -# Application definition | 31 | +# Application definition |
32 | - | 32 | + |
33 | -INSTALLED_APPS = [ | 33 | +INSTALLED_APPS = [ |
34 | - 'django.contrib.admin', | 34 | + 'django.contrib.admin', |
35 | - 'django.contrib.auth', | 35 | + 'django.contrib.auth', |
36 | - 'django.contrib.contenttypes', | 36 | + 'django.contrib.contenttypes', |
37 | - 'django.contrib.sessions', | 37 | + 'django.contrib.sessions', |
38 | - 'django.contrib.messages', | 38 | + 'django.contrib.messages', |
39 | - 'django.contrib.staticfiles', | 39 | + 'django.contrib.staticfiles', |
40 | - 'rest_framework', | 40 | + 'rest_framework', |
41 | -] | 41 | + 'api.apps.ApiConfig', |
42 | - | 42 | +] |
43 | -MIDDLEWARE = [ | 43 | + |
44 | - 'django.middleware.security.SecurityMiddleware', | 44 | +MIDDLEWARE = [ |
45 | - 'django.contrib.sessions.middleware.SessionMiddleware', | 45 | + 'django.middleware.security.SecurityMiddleware', |
46 | - 'django.middleware.common.CommonMiddleware', | 46 | + 'django.contrib.sessions.middleware.SessionMiddleware', |
47 | - 'django.middleware.csrf.CsrfViewMiddleware', | 47 | + 'django.middleware.common.CommonMiddleware', |
48 | - 'django.contrib.auth.middleware.AuthenticationMiddleware', | 48 | + 'django.middleware.csrf.CsrfViewMiddleware', |
49 | - 'django.contrib.messages.middleware.MessageMiddleware', | 49 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', |
50 | - 'django.middleware.clickjacking.XFrameOptionsMiddleware', | 50 | + 'django.contrib.messages.middleware.MessageMiddleware', |
51 | -] | 51 | + 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
52 | - | 52 | +] |
53 | -ROOT_URLCONF = 'khudrive.urls' | 53 | + |
54 | - | 54 | +ROOT_URLCONF = 'khudrive.urls' |
55 | -TEMPLATES = [ | 55 | + |
56 | - { | 56 | +TEMPLATES = [ |
57 | - 'BACKEND': 'django.template.backends.django.DjangoTemplates', | 57 | + { |
58 | - 'DIRS': [], | 58 | + 'BACKEND': 'django.template.backends.django.DjangoTemplates', |
59 | - 'APP_DIRS': True, | 59 | + 'DIRS': [], |
60 | - 'OPTIONS': { | 60 | + 'APP_DIRS': True, |
61 | - 'context_processors': [ | 61 | + 'OPTIONS': { |
62 | - 'django.template.context_processors.debug', | 62 | + 'context_processors': [ |
63 | - 'django.template.context_processors.request', | 63 | + 'django.template.context_processors.debug', |
64 | - 'django.contrib.auth.context_processors.auth', | 64 | + 'django.template.context_processors.request', |
65 | - 'django.contrib.messages.context_processors.messages', | 65 | + 'django.contrib.auth.context_processors.auth', |
66 | - ], | 66 | + 'django.contrib.messages.context_processors.messages', |
67 | - }, | 67 | + ], |
68 | - }, | 68 | + }, |
69 | -] | 69 | + }, |
70 | - | 70 | +] |
71 | -WSGI_APPLICATION = 'khudrive.wsgi.application' | 71 | + |
72 | - | 72 | +WSGI_APPLICATION = 'khudrive.wsgi.application' |
73 | - | 73 | + |
74 | -# Database | 74 | + |
75 | -# https://docs.djangoproject.com/en/3.0/ref/settings/#databases | 75 | +# Database |
76 | - | 76 | +# https://docs.djangoproject.com/en/3.0/ref/settings/#databases |
77 | -DATABASES = { | 77 | +DATABASES = { |
78 | - 'default': { | 78 | + # 'default': { |
79 | - 'ENGINE': 'django.db.backends.sqlite3', | 79 | + # 'ENGINE': 'django.db.backends.sqlite3', |
80 | - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | 80 | + # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), |
81 | - } | 81 | + # } |
82 | -} | 82 | + 'default': { |
83 | - | 83 | + 'ENGINE': 'django.db.backends.postgresql', |
84 | - | 84 | + 'NAME': 'khuDrive', |
85 | -# Password validation | 85 | + 'USER': 'jooheekwon', |
86 | -# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators | 86 | + 'PASSWORD': '', |
87 | - | 87 | + 'HOST': 'localhost', |
88 | -AUTH_PASSWORD_VALIDATORS = [ | 88 | + 'PORT': '', |
89 | - { | 89 | + } |
90 | - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | 90 | +} |
91 | - }, | 91 | + |
92 | - { | 92 | + |
93 | - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | 93 | +# Password validation |
94 | - }, | 94 | +# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators |
95 | - { | 95 | + |
96 | - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | 96 | +AUTH_PASSWORD_VALIDATORS = [ |
97 | - }, | 97 | + { |
98 | - { | 98 | + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', |
99 | - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', | 99 | + }, |
100 | - }, | 100 | + { |
101 | -] | 101 | + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', |
102 | - | 102 | + }, |
103 | - | 103 | + { |
104 | -# Internationalization | 104 | + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', |
105 | -# https://docs.djangoproject.com/en/3.0/topics/i18n/ | 105 | + }, |
106 | - | 106 | + { |
107 | -LANGUAGE_CODE = 'en-us' | 107 | + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', |
108 | - | 108 | + }, |
109 | -TIME_ZONE = 'UTC' | 109 | +] |
110 | - | 110 | + |
111 | -USE_I18N = True | 111 | + |
112 | - | 112 | +# Internationalization |
113 | -USE_L10N = True | 113 | +# https://docs.djangoproject.com/en/3.0/topics/i18n/ |
114 | - | 114 | + |
115 | -USE_TZ = True | 115 | +LANGUAGE_CODE = 'en-us' |
116 | - | 116 | + |
117 | - | 117 | +TIME_ZONE = 'UTC' |
118 | -# Static files (CSS, JavaScript, Images) | 118 | + |
119 | -# https://docs.djangoproject.com/en/3.0/howto/static-files/ | 119 | +USE_I18N = True |
120 | - | 120 | + |
121 | -STATIC_URL = '/static/' | 121 | +USE_L10N = True |
122 | + | ||
123 | +USE_TZ = True | ||
124 | + | ||
125 | + | ||
126 | +# Static files (CSS, JavaScript, Images) | ||
127 | +# https://docs.djangoproject.com/en/3.0/howto/static-files/ | ||
128 | + | ||
129 | +STATIC_URL = '/static/' | ... | ... |
1 | -"""khudrive URL Configuration | 1 | +"""khudrive URL Configuration |
2 | - | 2 | + |
3 | -The `urlpatterns` list routes URLs to views. For more information please see: | 3 | +The `urlpatterns` list routes URLs to views. For more information please see: |
4 | - https://docs.djangoproject.com/en/3.0/topics/http/urls/ | 4 | + https://docs.djangoproject.com/en/3.0/topics/http/urls/ |
5 | -Examples: | 5 | +Examples: |
6 | -Function views | 6 | +Function views |
7 | - 1. Add an import: from my_app import views | 7 | + 1. Add an import: from my_app import views |
8 | - 2. Add a URL to urlpatterns: path('', views.home, name='home') | 8 | + 2. Add a URL to urlpatterns: path('', views.home, name='home') |
9 | -Class-based views | 9 | +Class-based views |
10 | - 1. Add an import: from other_app.views import Home | 10 | + 1. Add an import: from other_app.views import Home |
11 | - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') | 11 | + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') |
12 | -Including another URLconf | 12 | +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.contrib import admin | 16 | +from django.urls import include, path |
17 | -from django.urls import path | 17 | +from rest_framework import routers |
18 | - | 18 | +from django.contrib import admin |
19 | -urlpatterns = [ | 19 | +from api import views |
20 | - path('admin/', admin.site.urls), | 20 | +from django.conf.urls import url |
21 | -] | 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. | ||
29 | +urlpatterns = [ | ||
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 | + | ||
40 | +] | ... | ... |
1 | -""" | 1 | +""" |
2 | -WSGI config for khudrive project. | 2 | +WSGI config for khudrive project. |
3 | - | 3 | + |
4 | -It exposes the WSGI callable as a module-level variable named ``application``. | 4 | +It exposes the WSGI callable as a module-level variable named ``application``. |
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/howto/deployment/wsgi/ | 7 | +https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ |
8 | -""" | 8 | +""" |
9 | - | 9 | + |
10 | -import os | 10 | +import os |
11 | - | 11 | + |
12 | -from django.core.wsgi import get_wsgi_application | 12 | +from django.core.wsgi import get_wsgi_application |
13 | - | 13 | + |
14 | -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'khudrive.settings') | 14 | +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'khudrive.settings') |
15 | - | 15 | + |
16 | -application = get_wsgi_application() | 16 | +application = get_wsgi_application() | ... | ... |
-
Please register or login to post a comment