commit 9bd01af2a5c72a2ac62002113d69b279a2e5f5c7
parent d715197b2f8470dada38cdbb3ab7bf95824c5e21
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 27 Apr 2017 15:33:02 -0400
Disallow inPublications for linked-file attachments
Diffstat:
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js
@@ -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
diff --git a/test/tests/itemTest.js b/test/tests/itemTest.js
@@ -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 () {