Toggle navigation
Toggle navigation
This project
Loading...
Sign in
cse437_e
/
smartdoorlock-backend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김유현
2020-11-20 10:45:30 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
98d3daedfb8886f0aafa83e04248f52c7bfd8900
98d3daed
1 parent
2165416d
Modify
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
api/admin.py
api/views.py
api/admin.py
View file @
98d3dae
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
...
...
api/views.py
View file @
98d3dae
...
...
@@ -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
({
...
...
Please
register
or
login
to post a comment