권주희

Merge branch 'feature/item_api' into 'develop'

Feature/item api



See merge request !4
1 +# Generated by Django 3.0.6 on 2020-06-06 08:17
2 +
3 +from django.db import migrations
4 +
5 +
6 +class Migration(migrations.Migration):
7 +
8 + dependencies = [
9 + ('api', '0002_auto_20200605_1851'),
10 + ]
11 +
12 + operations = [
13 + migrations.RenameField(
14 + model_name='shareditem',
15 + old_name='valid',
16 + new_name='expires',
17 + ),
18 + ]
1 +# Generated by Django 3.0.6 on 2020-06-06 08:24
2 +
3 +from django.db import migrations, models
4 +
5 +
6 +class Migration(migrations.Migration):
7 +
8 + dependencies = [
9 + ('api', '0003_auto_20200606_0817'),
10 + ]
11 +
12 + operations = [
13 + migrations.AddField(
14 + model_name='shareditem',
15 + name='created_time',
16 + field=models.DateTimeField(auto_now=True),
17 + ),
18 + migrations.AddField(
19 + model_name='user',
20 + name='created_time',
21 + field=models.DateTimeField(auto_now=True),
22 + ),
23 + migrations.AlterField(
24 + model_name='item',
25 + name='created_time',
26 + field=models.DateTimeField(auto_now=True),
27 + ),
28 + ]
...@@ -11,7 +11,7 @@ class Item(models.Model): ...@@ -11,7 +11,7 @@ class Item(models.Model):
11 user_id = models.IntegerField() 11 user_id = models.IntegerField()
12 size = models.IntegerField() 12 size = models.IntegerField()
13 is_deleted = models.BooleanField(default = False) 13 is_deleted = models.BooleanField(default = False)
14 - created_time = models.DateTimeField(blank = False) 14 + created_time = models.DateTimeField(auto_now=True)
15 updated_time = models.DateTimeField() 15 updated_time = models.DateTimeField()
16 status = models.BooleanField() 16 status = models.BooleanField()
17 17
...@@ -24,9 +24,9 @@ class Item(models.Model): ...@@ -24,9 +24,9 @@ class Item(models.Model):
24 class SharedItem(models.Model): 24 class SharedItem(models.Model):
25 item_id = models.IntegerField() 25 item_id = models.IntegerField()
26 #file_id? 26 #file_id?
27 - valid = models.DateTimeField() 27 + expires = models.DateTimeField()
28 password = models.CharField(max_length = 20) 28 password = models.CharField(max_length = 20)
29 - 29 + created_time = models.DateTimeField(auto_now=True)
30 class Meta: 30 class Meta:
31 ordering = ['item_id'] 31 ordering = ['item_id']
32 32
...@@ -38,6 +38,6 @@ class User(models.Model): ...@@ -38,6 +38,6 @@ class User(models.Model):
38 password = models.CharField(max_length = 20) 38 password = models.CharField(max_length = 20)
39 total_size = models.IntegerField() 39 total_size = models.IntegerField()
40 current_size = models.IntegerField() 40 current_size = models.IntegerField()
41 - 41 + created_time = models.DateTimeField(auto_now=True)
42 class Meta: 42 class Meta:
43 ordering = ['int_id'] 43 ordering = ['int_id']
......
1 from django.contrib.auth.models import User, Group 1 from django.contrib.auth.models import User, Group
2 from rest_framework import serializers 2 from rest_framework import serializers
3 -from api.models import Item 3 +from api.models import Item, SharedItem
4 4
5 5
6 class UserSerializer(serializers.HyperlinkedModelSerializer): 6 class UserSerializer(serializers.HyperlinkedModelSerializer):
...@@ -17,3 +17,8 @@ class ItemSerializer(serializers.ModelSerializer): ...@@ -17,3 +17,8 @@ class ItemSerializer(serializers.ModelSerializer):
17 class Meta: 17 class Meta:
18 model = Item 18 model = Item
19 fields = '__all__' 19 fields = '__all__'
20 +
21 +class SharedItemSerializer(serializers.ModelSerializer):
22 + class Meta:
23 + model = Item
24 + fields = '__all__'
......
This diff is collapsed. Click to expand it.
...@@ -22,12 +22,14 @@ from django.conf.urls import url ...@@ -22,12 +22,14 @@ from django.conf.urls import url
22 router = routers.DefaultRouter() 22 router = routers.DefaultRouter()
23 router.register(r'users', views.UserViewSet) 23 router.register(r'users', views.UserViewSet)
24 router.register(r'items', views.ItemViewSet) 24 router.register(r'items', views.ItemViewSet)
25 +router.register(r'items', views.SharedItemViewSet)
25 26
26 # Wire up our API using automatic URL routing. 27 # Wire up our API using automatic URL routing.
27 # Additionally, we include login URLs for the browsable API. 28 # Additionally, we include login URLs for the browsable API.
28 urlpatterns = [ 29 urlpatterns = [
29 path('admin/', admin.site.urls), 30 path('admin/', admin.site.urls),
30 path('', include(router.urls)), 31 path('', include(router.urls)),
31 - url(r'^upload/$', views.ItemViewSet.upload, name='upload'), 32 + url(r'^search/$', views.ItemViewSet.search, name='search'),
32 - url(r'^status/$', views.ItemViewSet.status, name='status'), 33 + url(r'^<int:pk>/share/$', views.SharedItemViewSet.share, name='share'),
34 +
33 ] 35 ]
......