Beispiel #1
0
 def post(self, request, format=None):
     serializer = GeoLocationSerializer(data=request.data)
     if request.data['username'] in CreatedBy().values_key(
             'username',
             CreatedBy().all()):
         if serializer.is_valid():
             serializer.save()
             return Response(serializer.data,
                             status=status.HTTP_201_CREATED)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Beispiel #2
0
 def delete(self, request, id, format=None):
     response = CreatedBy().delete(id)
     if response == 204:
         return Response(status=status.HTTP_204_NO_CONTENT)
     return Response(status=status.HTTP_400_BAD_REQUEST)
Beispiel #3
0
 def put(self, request, id, format=None):
     createdby = CreatedBy().put(id, request.data)
     if createdby.status_code == 200:
         return Response(createdby.json(), status=status.HTTP_200_OK)
     return Response(status=status.HTTP_400_BAD_REQUEST)
Beispiel #4
0
 def get_object(self, id):
     createdby = CreatedBy().get(id)
     if createdby != 200:
         raise Http404
     return createdby
Beispiel #5
0
 def post(self, request, format=None):
     createdby = CreatedBy().create(request.data)
     if createdby.status_code == 201:
         return Response(createdby.data, status=status.HTTP_201_CREATED)
     return Response(status=status.HTTP_400_BAD_REQUEST)
Beispiel #6
0
 def get(self, request, format=None):
     print(CreatedBy().values_key('username', CreatedBy().all()))
     return Response(CreatedBy().all())
Beispiel #7
0
 def create(self, validated_data):
     print(validated_data)
     return CreatedBy().create(validated_data)