김유현

Modify

from django.contrib import admin
from .models import Video, Device, RemoteHistory, Lock, Record, Door
from .models import Video, Device, RemoteHistory, Lock, Record, Door, AddDevice
# Register your models here.
admin.site.register(Door)
admin.site.register(Video)
......@@ -7,3 +8,4 @@ admin.site.register(Device)
admin.site.register(RemoteHistory)
admin.site.register(Lock)
admin.site.register(Record)
admin.site.register(AddDevice)
\ No newline at end of file
......
......@@ -117,6 +117,7 @@ class Devices(APIView) :
if request_id == None :
raise FieldDoesNotExist
queryset = Device.objects.create(rfid_id = request_id)
queryset.save()
return Response({
'msg' : 'success device add'
})
......@@ -168,12 +169,16 @@ class Remote(APIView):
if device_name == None :
raise FieldDoesNotExist
else:
# 잠금 상태 변경
target = Lock.objects.get(id=1)
serializer = LockSerializer(target, many=False)
state = serializer.data['state']
if state == True:
print(">> 원격 잠금해제 요청이 들어옴")
# 기록에 저장
now = datetime.datetime.now()
queryset = Device.objects.create(device_name=device_name, created=now)
queryset.save()
# 잠금 해제 상태로 변경
target.state = False
target.save()
return Response({
......