Ejemplo n.º 1
0
def doc_catsave(request):
    "method for saving docid and catid"
    serializer = DoclistSerializer(data=request.data)
    if serializer.is_valid():
        serializer.save()
        return Response(serializer.data, status=status.HTTP_201_CREATED)
    else:
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 2
0
def doc_catsave(request):
    "method for saving docid and catid"
    serializer = DoclistSerializer(data=request.data)
    if serializer.is_valid():
        serializer.save()
        return Response(serializer.data, status=status.HTTP_201_CREATED)
    else:
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 3
0
def doc_catupdate(request, pk):
    "method for updating docid with catid in case user deletes the app by mistake"
    try:
        doc = Doclist.objects.get(usrID=pk)
    except Doclist.DoesNotExist:
        return Response(status=status.HTTP_404_NOT_FOUND)
    serializer = DoclistSerializer(doc, data=request.data)
    if serializer.is_valid():
        serializer.save()
        return Response(serializer.data)
    else:
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Ejemplo n.º 4
0
def doc_catupdate(request,pk):
    "method for updating docid with catid in case user deletes the app by mistake"
    try:
        doc = Doclist.objects.get(usrID=pk)
    except Doclist.DoesNotExist:
        return Response(status=status.HTTP_404_NOT_FOUND)
    serializer = DoclistSerializer(doc, data=request.data)
    if serializer.is_valid():
        serializer.save()
        return Response(serializer.data)
    else:
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)