Esempio n. 1
0
	def update (self, request, pk, id) :

		gap = Gap.objects.filter(user_id=pk, id=id).first()
		if (gap is not None) :
			serializer = GapSerializer(gap, partial=True, data=request.data)
			if (serializer.is_valid()) :
				serializer.save()
				return Response(serializer.data)
			return Response(serializer.error_messages, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
		else :
			return Response(status=status.HTTP_400_BAD_REQUEST)
Esempio n. 2
0
    def update(self, request, pk, id):

        gap = Gap.objects.filter(user_id=pk, id=id).first()
        if (gap is not None):
            serializer = GapSerializer(gap, partial=True, data=request.data)
            if (serializer.is_valid()):
                serializer.save()
                return Response(serializer.data)
            return Response(serializer.error_messages,
                            status=status.HTTP_500_INTERNAL_SERVER_ERROR)
        else:
            return Response(status=status.HTTP_400_BAD_REQUEST)
Esempio n. 3
0
	def create (self, request) :

		serializer = GapSerializer(data=request.data)

		if not serializer.is_valid() :
			serializer = GapSerializer(data=request.data, exclude=('name',))
			if not serializer.is_valid() :
				serializer = GapSerializer(data=request.data, exclude=('location',))
				if not serializer.is_valid() :
					return Response(serializer.error_messages, status=status.HTTP_400_BAD_REQUEST)
		serializer.save()
		return Response(serializer.data)
Esempio n. 4
0
    def create(self, request):

        serializer = GapSerializer(data=request.data)

        if not serializer.is_valid():
            serializer = GapSerializer(data=request.data, exclude=('name', ))
            if not serializer.is_valid():
                serializer = GapSerializer(data=request.data,
                                           exclude=('location', ))
                if not serializer.is_valid():
                    return Response(serializer.error_messages,
                                    status=status.HTTP_400_BAD_REQUEST)
        serializer.save()
        return Response(serializer.data)