Esempio n. 1
0
 def post(self, request, pk, format=None):
     user = get_object(self, pk)
     serializer = UserSerializer(user, data=request.data)
     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)
Esempio n. 2
0
class CaseDetailView(APIView):
    permission_classes = (IsAuthenticated,)
    model = Case

    @access_permission('case_view')
    def get(self, request,pk, format=None):
        case = get_object(self,pk)
        serializer = CaseSerializer(case)
        return Response(serializer.data)
Esempio n. 3
0
class CaseDeleteView(APIView):
    permission_classes = (IsAuthenticated,)
    model = Case

    @access_permission('case_delete')
    def delete(self, request, pk, format=None):
        case = get_object(self,pk)
        case.delete()
        return Response(status=status.HTTP_204_NO_CONTENT)
Esempio n. 4
0
class CaseUpdateView(APIView):
    permission_classes = (IsAuthenticated,)
    model = Case

    @access_permission('case_edit')
    def post(self, request,pk, format=None):
        case = get_object(self,pk)
        serializer = CaseSerializer(case,data=request.data)
        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)
Esempio n. 5
0
 def get(self, request, pk, format=None):
     user = get_object(self, pk)
     serializer = UserSerializer(user)
     return Response(serializer.data)
Esempio n. 6
0
 def delete(self, request, pk, format=None):
     user = get_object(self, pk)
     user.delete()
     return Response(status=status.HTTP_204_NO_CONTENT)
Esempio n. 7
0
 def get(self, request,pk, format=None):
     task = get_object(self,pk)
     serializer = TaskSerializer(task)
     return Response(serializer.data)