Fakultas Ilmu Komputer UI

Commit b022cc6e authored by M. Abdurrahman's avatar M. Abdurrahman
Browse files

[REFACTOR] slight refactor on Facsilitas handler for tag and rating

parent 68fa019d
Pipeline #42187 passed with stages
in 3 minutes and 52 seconds
......@@ -109,9 +109,13 @@ Make `POST` request to API endpoint `/informasi-lokasi/lokasi/add-fasilitas/*nam
* TEMPAT_PARKIR_DISABILITAS = 'PK'
* RUNNING_TEXT = 'RT'
* TEMPAT_PARKIR_BIASA = 'TB'
* Put as a String separated by space
* example: "KR LF TD"
<br>
* `deskripsi` : Facility description.
* `rating` : rating for the Facility, an integer 1-5.
<br>
<b>Make sure you have token it your request header.</b>
<b>Add this to your request header. `Authorization` with value `token *your_token_from_request*`</b>
......
......@@ -367,7 +367,8 @@ class InformasiFasilitasViewTest(TestCase):
response = client.post(reverse('add-fasilitas', kwargs={'nama_lokasi':'Mall'}),
{'deskripsi' : 'penjelasan fasilitas',
'rating' : 2})
'rating' : 2,
'tag' : 'KR RT'})
self.assertEqual(response.status_code, 201)
def test_cannot_get_add_fasilitas(self):
......
......@@ -102,9 +102,13 @@ def add_fasilitas(request, nama_lokasi):
lokasi = Lokasi.objects.get(name=nama_lokasi)
user = User.objects.get(email=str(request.user))
deskripsi = request.POST['deskripsi']
rating = request.POST['rating']
tag = request.POST['tag'].split()
fasilitas = Fasilitas.objects.create(lokasi=lokasi,
user=user,
deskripsi=deskripsi)
deskripsi=deskripsi,
rating=rating,
tag=tag)
return JsonResponse({'response' : 'fasilitas added', 'id':fasilitas.id}, status = 201)
else:
return JsonResponse({'response' : request_error_message("post")}, status = 400)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment