示例#1
0
def CardUsers_list(request):
    if request.method == 'GET':
        cardUsers = CardUsers.objects.all()
        serializer = CardUsersSerializer(cardUsers, many=True)
        return JSONResponse(serializer.data)

    elif request.method == 'POST':
        data = JSONParser().parse(request)
        serializer = CardUsersSerializer(data=data)
        if serializer.is_valid():
            serializer.save()
            return JSONResponse(serializer.data, status=201)
        else:
            return JSONResponse(serializer.errors, status=400)
示例#2
0
def CardUsers_list(request):
	if request.method == 'GET':
		cardUsers = CardUsers.objects.all()
		serializer = CardUsersSerializer(cardUsers, many=True)
		return JSONResponse(serializer.data)

	elif request.method == 'POST':
		data = JSONParser().parse(request)
		serializer = CardUsersSerializer(data=data)
		if serializer.is_valid():
			serializer.save()
			return JSONResponse(serializer.data, status=201)
		else:
			return JSONResponse(serializer.errors, status=400)
示例#3
0
def CardUsers_card(request, card):
    try:
        cardUsers = CardUsers.objects.get(cardId=card)
    except CardUsers.DoesNotExist:
        return HttpResponse(status=404)
    if request.method == 'GET':
        serializer = CardUsersSerializer(cardUsers)
        return JSONResponse(serializer.data)
    elif request.method == 'PUT':
        data = JSONParser().parse(request)
        serializer = CardUsersSerializer(cardUsers, data=data)
        if serializer.is_valid():
            serializer.save()
            return JSONResponse(serializer.data)
        else:
            return JSONResponse(serializer.errors, status=400)
    if request.method == 'DELETE':
        cardUsers.delete()
        return HttpResponse(status=204)
示例#4
0
def CardUsers_card(request, card):
	try:
		cardUsers = CardUsers.objects.get(cardId=card)
	except CardUsers.DoesNotExist:
		return HttpResponse(status=404)
	if request.method == 'GET':
		serializer = CardUsersSerializer(cardUsers)
		return JSONResponse(serializer.data)
	elif request.method == 'PUT':
		data = JSONParser().parse(request)
		serializer = CardUsersSerializer(cardUsers, data=data)
		if serializer.is_valid():
			serializer.save()
			return JSONResponse(serializer.data)
		else:
			return JSONResponse(serializer.errors, status=400)
	if request.method == 'DELETE':
		cardUsers.delete()
		return HttpResponse(status=204)