From 8436b67260ad351bb6d4869782e0a6ab55f90f11 Mon Sep 17 00:00:00 2001 From: Michael Mazour Date: Mon, 2 Jul 2018 11:12:42 +0100 Subject: [PATCH 1/2] Include project's v1 ID in export requests If a project was imported from v1, include its v1 ID when making an export request back to v1. Use case: v1 project exported via ScholarOne and then migrated to v2 needs to be linked up to its earlier v1 export records. --- .../web/app/coffee/Features/Exports/ExportsHandler.coffee | 1 + .../web/test/unit/coffee/Exports/ExportsHandlerTests.coffee | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/web/app/coffee/Features/Exports/ExportsHandler.coffee b/services/web/app/coffee/Features/Exports/ExportsHandler.coffee index adedfc582b..67460826c4 100644 --- a/services/web/app/coffee/Features/Exports/ExportsHandler.coffee +++ b/services/web/app/coffee/Features/Exports/ExportsHandler.coffee @@ -56,6 +56,7 @@ module.exports = ExportsHandler = self = rootDocPath: rootDoc[1]?.fileSystem historyId: project.overleaf?.history?.id historyVersion: historyVersion + v1ProjectId: project.overleaf?.id user: id: user_id firstName: user.first_name diff --git a/services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee b/services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee index e8beccddf9..71a3e75672 100644 --- a/services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee +++ b/services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee @@ -64,6 +64,7 @@ describe 'ExportsHandler', -> @project = id: @project_id overleaf: + id: @project_history_id # for projects imported from v1 history: id: @project_history_id @user = @@ -90,12 +91,13 @@ describe 'ExportsHandler', -> .should.equal true it "should return export data", -> - expected_export_data = + expected_export_data = project: id: @project_id rootDocPath: @rootDocPath historyId: @project_history_id historyVersion: @historyVersion + v1ProjectId: @project_history_id user: id: @user_id firstName: @user.first_name @@ -126,6 +128,7 @@ describe 'ExportsHandler', -> rootDocPath: @rootDocPath historyId: @project_history_id historyVersion: @historyVersion + v1ProjectId: @project_history_id user: id: @user_id firstName: @custom_first_name From 235534d269fe53f1d4ff28fc034a0c4bf0586a3d Mon Sep 17 00:00:00 2001 From: Michael Mazour Date: Tue, 3 Jul 2018 10:15:51 +0100 Subject: [PATCH 2/2] Also include user's v1 ID in export requests --- .../web/app/coffee/Features/Exports/ExportsHandler.coffee | 3 ++- .../web/test/unit/coffee/Exports/ExportsHandlerTests.coffee | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/services/web/app/coffee/Features/Exports/ExportsHandler.coffee b/services/web/app/coffee/Features/Exports/ExportsHandler.coffee index 67460826c4..17a0798ead 100644 --- a/services/web/app/coffee/Features/Exports/ExportsHandler.coffee +++ b/services/web/app/coffee/Features/Exports/ExportsHandler.coffee @@ -31,7 +31,7 @@ module.exports = ExportsHandler = self = ProjectLocator.findRootDoc {project: results.project, project_id: project_id}, cb ] user: (cb) -> - UserGetter.getUser user_id, {first_name: 1, last_name: 1, email: 1}, cb + UserGetter.getUser user_id, {first_name: 1, last_name: 1, email: 1, overleaf: 1}, cb historyVersion: (cb) -> self._requestVersion project_id, cb @@ -63,6 +63,7 @@ module.exports = ExportsHandler = self = lastName: user.last_name email: user.email orcidId: null # until v2 gets ORCID + v1UserId: user.overleaf?.id destination: brandVariationId: brand_variation_id options: diff --git a/services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee b/services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee index 71a3e75672..a210532e9b 100644 --- a/services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee +++ b/services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee @@ -72,6 +72,8 @@ describe 'ExportsHandler', -> first_name: 'Arthur' last_name: 'Author' email: 'arthur.author@arthurauthoring.org' + overleaf: + id: 876 @rootDocPath = 'main.tex' @historyVersion = 777 @ProjectGetter.getProject = sinon.stub().yields(null, @project) @@ -104,6 +106,7 @@ describe 'ExportsHandler', -> lastName: @user.last_name email: @user.email orcidId: null + v1UserId: 876 destination: brandVariationId: @brand_variation_id options: @@ -135,6 +138,7 @@ describe 'ExportsHandler', -> lastName: @custom_last_name email: @user.email orcidId: null + v1UserId: 876 destination: brandVariationId: @brand_variation_id options: