Example #1
0
File: views.py Project: crs4/ACTIVE
    def post(self, request, format=None):
        serializer = PermissionSerializer(data=request.data)
        if serializer.is_valid():
            serializer.save()
            logger.debug('Created a new Permission object')
            return Response(serializer.data, status=status.HTTP_201_CREATED)

        logger.error('Error on creation of a new Permission object')
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Example #2
0
File: views.py Project: crs4/ACTIVE
    def put(self, request, pk, format=None):
        permission = self.get_object(pk)
        serializer = PermissionSerializer(permission, data=request.data)
        if serializer.is_valid():
            serializer.save()
            logger.debug('Updated data for Permission object with id ' + str(pk))
            return Response(serializer.data)

        logger.error('Error on data update for Permission object with id ' + str(pk))
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)