无法保存权限
Not able to save permission
我正在尝试为 user/project 创建新的项目权限,但保存失败,因为 "No valid Project provided"。查看网络日志,服务器调用中的 RequestPayload 为空 ({"ProjectPermission":{}})。有什么想法吗?
_addViewPermission: function() {
this.getModel().then({
success: this.createPP,
scope: this
}).then({
success: this.readPP,
scope: this
}).then({
success: function(result) {
console.log('success', result);
},
failure: function(error) {
console.log('oh noes!', error);
}
});
},
getModel: function() {
return Rally.data.ModelFactory.getModel({
type: 'ProjectPermission'
});
},
createPP: function(model) {
var permission = Ext.create(model, {
Project: "/project/51063976712",
Role: 'Viewer',
User: "/user/43049588391"
});
return permission.save();
},
readPP: function(permission){
console.log(permisson);
return permission.self.load(permission.getId(), {
fetch: ['Project', 'User', 'Role']
});
}
这是 AppSDK 中长期存在的奇怪缺陷 - 抱歉让您误会了!我试图在上面找到另一个Whosebug post,但也许这里还没有被问到。
无论如何,它对您来说失败的原因是“项目”字段被标记为只读,即使它在创建时是必需的。因此,即使您明确指定,代理也不会沿着项目字段发送。
解决方法是在创建和保存新记录之前简单地将项目字段标记为可持久化。
model.getField('Project').persist = true;
我正在尝试为 user/project 创建新的项目权限,但保存失败,因为 "No valid Project provided"。查看网络日志,服务器调用中的 RequestPayload 为空 ({"ProjectPermission":{}})。有什么想法吗?
_addViewPermission: function() {
this.getModel().then({
success: this.createPP,
scope: this
}).then({
success: this.readPP,
scope: this
}).then({
success: function(result) {
console.log('success', result);
},
failure: function(error) {
console.log('oh noes!', error);
}
});
},
getModel: function() {
return Rally.data.ModelFactory.getModel({
type: 'ProjectPermission'
});
},
createPP: function(model) {
var permission = Ext.create(model, {
Project: "/project/51063976712",
Role: 'Viewer',
User: "/user/43049588391"
});
return permission.save();
},
readPP: function(permission){
console.log(permisson);
return permission.self.load(permission.getId(), {
fetch: ['Project', 'User', 'Role']
});
}
这是 AppSDK 中长期存在的奇怪缺陷 - 抱歉让您误会了!我试图在上面找到另一个Whosebug post,但也许这里还没有被问到。
无论如何,它对您来说失败的原因是“项目”字段被标记为只读,即使它在创建时是必需的。因此,即使您明确指定,代理也不会沿着项目字段发送。
解决方法是在创建和保存新记录之前简单地将项目字段标记为可持久化。
model.getField('Project').persist = true;