parent
8763190328
commit
174f1aadde
2 changed files with 44 additions and 9 deletions
|
@ -1374,15 +1374,37 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
|
|||
//}
|
||||
}
|
||||
if (createdByUserID || lastModifiedByUserID) {
|
||||
let sql = "REPLACE INTO groupItems VALUES (?, ?, ?)";
|
||||
yield Zotero.DB.queryAsync(
|
||||
sql,
|
||||
[
|
||||
itemID,
|
||||
createdByUserID || null,
|
||||
lastModifiedByUserID || null
|
||||
]
|
||||
);
|
||||
try {
|
||||
let sql = "REPLACE INTO groupItems VALUES (?, ?, ?)";
|
||||
yield Zotero.DB.queryAsync(
|
||||
sql,
|
||||
[
|
||||
itemID,
|
||||
createdByUserID || null,
|
||||
lastModifiedByUserID || null
|
||||
]
|
||||
);
|
||||
}
|
||||
// TODO: Use schema update step to add username to users table if group library
|
||||
// and no current name
|
||||
catch (e) {
|
||||
let username = yield Zotero.DB.valueQueryAsync(
|
||||
"SELECT value FROM settings WHERE setting='account' AND key='username'"
|
||||
);
|
||||
if (username) {
|
||||
yield Zotero.Users.setCurrentName(username);
|
||||
|
||||
let sql = "REPLACE INTO groupItems VALUES (?, ?, ?)";
|
||||
yield Zotero.DB.queryAsync(
|
||||
sql,
|
||||
[
|
||||
itemID,
|
||||
createdByUserID || null,
|
||||
lastModifiedByUserID || null
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1750,6 +1750,19 @@ describe("Zotero.Item", function () {
|
|||
);
|
||||
assert.lengthOf(annotationIDs, 1);
|
||||
});
|
||||
|
||||
it("should set username as name if not set for library item", async function () {
|
||||
await Zotero.Users.setCurrentUserID(1);
|
||||
var username = Zotero.Utilities.randomString();
|
||||
await Zotero.Users.setCurrentUsername(username);
|
||||
await Zotero.DB.queryAsync("DELETE FROM users");
|
||||
|
||||
var group = await createGroup();
|
||||
var libraryID = group.libraryID;
|
||||
var item = await createDataObject('item', { libraryID });
|
||||
|
||||
assert.equal(Zotero.Users.getCurrentName(), username);
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue