Disallow inPublications for linked-file attachments

This commit is contained in:
Dan Stillman 2017-04-27 15:33:02 -04:00
parent d715197b2f
commit 9bd01af2a5
2 changed files with 20 additions and 3 deletions

View file

@ -1513,8 +1513,13 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
}
}
if (this._inPublications && !this.isRegularItem() && !parentItemID) {
throw new Error("Top-level attachments and notes cannot be added to My Publications");
if (this._inPublications) {
if (!this.isRegularItem() && !parentItemID) {
throw new Error("Top-level attachments and notes cannot be added to My Publications");
}
if (this.isAttachment() && this.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_FILE) {
throw new Error("Linked-file attachments cannot be added to My Publications");
}
}
// Trashed status

View file

@ -363,7 +363,19 @@ describe("Zotero.Item", function () {
"SELECT COUNT(*) FROM publicationsItems WHERE itemID=?", item.id)),
0
);
})
});
it("should be invalid for linked-file attachments", function* () {
var item = yield createDataObject('item', { inPublications: true });
var attachment = yield Zotero.Attachments.linkFromFile({
file: OS.Path.join(getTestDataDirectory().path, 'test.png'),
parentItemID: item.id
});
attachment.inPublications = true;
var e = yield getPromiseError(attachment.saveTx());
assert.ok(e);
assert.include(e.message, "Linked-file attachments cannot be added to My Publications");
});
});
describe("#parentID", function () {