Fakultas Ilmu Komputer UI

Commit 993f606e authored by Bimo Iman Smartadi's avatar Bimo Iman Smartadi
Browse files

[REFACTOR] Deleted commented line

parent 2af268bf
Pipeline #40897 passed with stages
in 3 minutes and 30 seconds
......@@ -10,11 +10,8 @@ from rest_framework.authentication import TokenAuthentication
from .serializers import LokasiSerializer
from .models import Lokasi, Fasilitas, Komentar
# Create your views here.
#class LokasiViewSet(viewsets.ModelViewSet):
# queryset = Lokasi.objects.all().order_by('name')
# serializer_class = LokasiSerializer
def request_error_message(request):
return "get {} request instead".format(request)
@csrf_exempt
@api_view(['GET'])
......@@ -26,7 +23,7 @@ def lokasi_list(request):
serializer = LokasiSerializer(lokasi_list, many=True)
return JsonResponse(serializer.data, safe=False)
else:
return JsonResponse({'response' : 'try get request instead'}, status = 400)
return JsonResponse({'response' : request_error_message("get")}, status = 400)
@api_view(['GET'])
@authentication_classes([])
......@@ -38,7 +35,7 @@ def lokasi_details(request,name):
serializer = LokasiSerializer(lokasi)
return JsonResponse(serializer.data, safe=False)
else:
return JsonResponse({'response' : 'try get request instead'}, status = 400)
return JsonResponse({'response' : request_error_message("get")}, status = 400)
except KeyError as e:
return JsonResponse({'response':'bad request. {} key needed'.format(str(e))}, status = 500)
except:
......@@ -59,7 +56,7 @@ def add_lokasi(request):
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)
else:
return JsonResponse({'response' : 'try post request instead'}, status = 400)
return JsonResponse({'response' : request_error_message("post")}, status = 400)
except KeyError as e:
return JsonResponse({'response':'bad request. {} key needed'.format(str(e))}, status = 500)
......@@ -90,7 +87,7 @@ def list_fasilitas(request, nama_lokasi):
except KeyError as e:
return JsonResponse({'response':'bad request. {} key needed'.format(str(e))}, status = 500)
except:
return JsonResponse({'response': 'lokasi might not be here'}) # Create your views here.
return JsonResponse({'response': 'lokasi might not be here'})
@api_view(['POST'])
@authentication_classes([TokenAuthentication,])
......@@ -108,7 +105,7 @@ def add_fasilitas(request, nama_lokasi):
image=image)
return JsonResponse({'response' : 'fasilitas added', 'id':fasilitas.id}, status = 201)
else:
return JsonResponse({'response' : 'try post request instead'}, status = 400)
return JsonResponse({'response' : request_error_message("post")}, status = 400)
except KeyError as e:
return JsonResponse({'response':'bad request. {} key needed'.format(str(e))}, status = 500)
except:
......@@ -127,7 +124,7 @@ def detail_fasilitas(request, nama_lokasi, id):
"like":fasilitas.like, "dislike":fasilitas.dislike, "rating":fasilitas.rating, "tag":fasilitas.tag, "image":str(fasilitas.image), "is_verified":fasilitas.is_verified}
return JsonResponse(return_json, status = 201)
else:
return JsonResponse({'response' : 'try get request instead'}, status = 400)
return JsonResponse({'response' : request_error_message("get")}, status = 400)
except KeyError as e:
return JsonResponse({'response':'bad request. {} key needed'.format(str(e))}, status = 500)
except Exception as e:
......
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