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-23 23:16:43 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
891d6b2b164f8d4ff9db287b803808612ca9e66b
891d6b2b
1 parent
223523ba
기기 추가 요청 issue
PUT /api/device/request 로만 받도록 rfid_id를 사용하지 않음
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
8 deletions
api/views.py
api/views.py
View file @
891d6b2
...
...
@@ -96,10 +96,12 @@ class Devices(APIView) :
},
status
=
status
.
HTTP_400_BAD_REQUEST
)
# 기기 추가 요청
def
put
(
self
,
request
,
format
=
None
)
:
def
put
(
self
,
request
,
device_id
,
format
=
None
)
:
try
:
if
request
.
auth
==
None
:
raise
PermissionDenied
if
device_id
!=
"request"
:
raise
FieldDoesNotExist
print
(
request
.
body
)
data
=
json
.
loads
(
request
.
body
)
target
=
AddDevice
.
objects
.
get
(
id
=
1
)
...
...
@@ -109,13 +111,9 @@ class Devices(APIView) :
print
(
">> 기기추가 요청이 들어옴"
)
target
.
state
=
True
target
.
save
()
rfid_id
=
data
.
get
(
'rfid_id'
,
None
)
res
=
{
'rfid_id'
:
rfid_id
}
if
rfid_id
==
None
:
raise
FieldDoesNotExist
return
Response
(
res
,
status
=
status
.
HTTP_200_OK
)
return
Response
({
'msg'
:
'changed state successfully'
},
status
=
status
.
HTTP_200_OK
)
except
FieldDoesNotExist
as
error
:
return
Response
({
'error'
:
"FieldDoesNotExist "
,
...
...
Please
register
or
login
to post a comment