Exemplo 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)
Exemplo 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)
Exemplo n.º 3
0
    def cross(self, request, pk1, pk2):

        gaps_user1 = Gap.objects.filter(user_id=pk1)
        gaps_user2 = Gap.objects.filter(user_id=pk2)

        sharedGaps = Gap.crossGaps(gaps_user1, gaps_user2)

        ser = GapSerializer(sharedGaps, many=True)
        return Response(ser.data)
Exemplo 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)
Exemplo n.º 5
0
    def list(self, request, pk):

        gaps = Gap.objects.filter(user_id=pk)
        ser = GapSerializer(gaps, many=True)
        return Response(ser.data)
Exemplo n.º 6
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)