권주희

Merge branch 'feature/item_api' into 'develop'

Feature/item api



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