Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2020
PPL-C
DTB-Layanan Fasilitas Publik Penyandang Disabilitas
PoiPoLeGan-PPLapanganTembak-DTB Layanan Fasilitas Publik Penyandang Disabilitas-BE
Commits
f2b280b5
Commit
f2b280b5
authored
Apr 21, 2020
by
M. Abdurrahman
Browse files
[REFACTOR] serialize post request add-lokasi
parent
c78294ee
Pipeline
#42165
passed with stages
in 5 minutes and 4 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
informasi_fasilitas/tests.py
View file @
f2b280b5
...
...
@@ -196,8 +196,7 @@ class InformasiFasilitasViewTest(TestCase):
'latitude'
:
0.0
,
'longitude'
:
0.0
,
'alamat'
:
'Jl. Raya Bogor no.1, Jakarta'
,
'no_telp'
:
'081212123131'
,
'image'
:
None
})
'no_telp'
:
'081212123131'
})
self
.
assertEqual
(
response
.
status_code
,
201
)
def
test_cannot_get_add_lokasi
(
self
):
...
...
informasi_fasilitas/views.py
View file @
f2b280b5
...
...
@@ -51,14 +51,14 @@ def lokasi_details(request,name):
def
add_lokasi
(
request
):
try
:
if
request
.
method
==
'POST'
:
name
=
request
.
POST
[
'name'
]
l
at
itude
=
request
.
POST
[
'latitude'
]
longitude
=
request
.
POST
[
'longitude'
]
alamat
=
request
.
POST
[
'alamat'
]
no_telp
=
request
.
POST
[
'no_telp'
]
image
=
request
.
POST
[
'image'
]
Lokasi
.
objects
.
create
(
name
=
name
,
latitude
=
latitude
,
longitude
=
longitude
,
alamat
=
alamat
,
no_telp
=
no_telp
,
image
=
image
)
return
JsonResponse
(
{
'response'
:
'Location added'
,
'name'
:
name
}
,
status
=
201
)
d
at
a
=
request
.
POST
serializer
=
LokasiSerializer
(
data
=
data
)
if
serializer
.
is_valid
():
serializer
.
save
()
return
JsonResponse
(
serializer
.
data
,
status
=
201
)
else
:
return
JsonResponse
(
serializer
.
errors
,
status
=
400
)
else
:
return
JsonResponse
({
'response'
:
request_error_message
(
"post"
)},
status
=
400
)
except
KeyError
as
e
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment