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)
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)
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)
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)
def get(self, request, pk, format=None): user = get_object(self, pk) serializer = UserSerializer(user) return Response(serializer.data)
def delete(self, request, pk, format=None): user = get_object(self, pk) user.delete() return Response(status=status.HTTP_204_NO_CONTENT)
def get(self, request,pk, format=None): task = get_object(self,pk) serializer = TaskSerializer(task) return Response(serializer.data)