최지우

delete door_id in setting api

# Generated by Django 3.1.2 on 2020-11-04 11:24
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Device',
fields=[
('rfid_id', models.CharField(max_length=255, primary_key=True, serialize=False)),
('created', models.DateTimeField(default=django.utils.timezone.now)),
],
),
migrations.CreateModel(
name='Door',
fields=[
('door_id', models.CharField(max_length=255, primary_key=True, serialize=False)),
],
),
migrations.CreateModel(
name='History',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('device_name', models.CharField(max_length=255)),
('ctrtime', models.DateTimeField(default=django.utils.timezone.now)),
],
),
migrations.CreateModel(
name='Video',
fields=[
('vid_id', models.IntegerField(primary_key=True, serialize=False)),
('created', models.DateTimeField(default=django.utils.timezone.now)),
('s3_link', models.CharField(max_length=255)),
],
),
migrations.CreateModel(
name='Record',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('recording', models.BooleanField(default=True)),
('door', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.door')),
],
),
migrations.CreateModel(
name='Lock',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('state', models.BooleanField(default=True)),
('door', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.door')),
],
),
]
# Generated by Django 3.1.2 on 2020-11-10 10:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='lock',
name='door',
),
migrations.RemoveField(
model_name='record',
name='door',
),
migrations.AlterField(
model_name='lock',
name='id',
field=models.IntegerField(primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='record',
name='id',
field=models.IntegerField(primary_key=True, serialize=False),
),
]
......@@ -16,7 +16,7 @@ class Video(models.Model) :
s3_link = models.CharField(max_length = 255)
class Lock(models.Model) :
door = models.ForeignKey(Door, on_delete=models.CASCADE)
id = models.IntegerField(primary_key = True)
state = models.BooleanField(default = True)
class History(models.Model) :
......@@ -24,5 +24,5 @@ class History(models.Model) :
ctrtime = models.DateTimeField(default = timezone.now)
class Record(models.Model) :
door = models.ForeignKey(Door, on_delete=models.CASCADE)
id = models.IntegerField(primary_key = True)
recording = models.BooleanField(default = True)
\ No newline at end of file
......
......@@ -94,14 +94,10 @@ class CheckDate(APIView) :
class Recording(APIView) :
def get(self, request, format = None) :
try :
'''
request_id = request.GET.get('door_id')
target = Record.objects.filter(door_id = request_id)
'''
target = Record.objects.all()
serializer = RecordSerializer(target, many = True)
target = Record.objects.get(id = 1)
serializer = RecordSerializer(target, many = False)
res = {
'recording' : serializer.data
'recording' : serializer.data['recording']
}
return Response(res, status = status.HTTP_200_OK)
except FieldDoesNotExist as error :
......@@ -112,10 +108,7 @@ class Recording(APIView) :
def put(self, request, format = None) :
try :
request_id = request.GET.get('door_id')
if not request_id :
raise FieldDoesNotExist
target = Record.objects.filter(door_id = request_id)
target = Record.objects.filter(id = 1)
target.update(recording = request.data['recording'])
return Response(status = status.HTTP_200_OK)
except FieldDoesNotExist as error :
......