mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 09:55:20 -05:00
accept attributes rather than projectHistoryId to ProjectCreationHandler
This commit is contained in:
parent
78aefc2871
commit
9ccdf073c4
2 changed files with 21 additions and 13 deletions
|
@ -16,38 +16,42 @@ AnalyticsManger = require("../Analytics/AnalyticsManager")
|
||||||
|
|
||||||
module.exports = ProjectCreationHandler =
|
module.exports = ProjectCreationHandler =
|
||||||
|
|
||||||
createBlankProject : (owner_id, projectName, projectHistoryId, callback = (error, project) ->)->
|
createBlankProject : (owner_id, projectName, attributes, callback = (error, project) ->)->
|
||||||
metrics.inc("project-creation")
|
metrics.inc("project-creation")
|
||||||
if arguments.length == 3
|
if arguments.length == 3
|
||||||
callback = projectHistoryId
|
callback = attributes
|
||||||
projectHistoryId = null
|
attributes = null
|
||||||
|
|
||||||
ProjectDetailsHandler.validateProjectName projectName, (error) ->
|
ProjectDetailsHandler.validateProjectName projectName, (error) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
logger.log owner_id:owner_id, projectName:projectName, "creating blank project"
|
logger.log owner_id:owner_id, projectName:projectName, "creating blank project"
|
||||||
if projectHistoryId?
|
if attributes?
|
||||||
ProjectCreationHandler._createBlankProject owner_id, projectName, projectHistoryId, (error, project) ->
|
ProjectCreationHandler._createBlankProject owner_id, projectName, attributes, (error, project) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
AnalyticsManger.recordEvent(
|
AnalyticsManger.recordEvent(
|
||||||
owner_id, 'project-imported', { projectId: project._id, projectHistoryId: projectHistoryId }
|
owner_id, 'project-imported', { projectId: project._id, attributes: attributes }
|
||||||
)
|
)
|
||||||
callback(error, project)
|
callback(error, project)
|
||||||
else
|
else
|
||||||
HistoryManager.initializeProject (error, history) ->
|
HistoryManager.initializeProject (error, history) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
ProjectCreationHandler._createBlankProject owner_id, projectName, history?.overleaf_id, (error, project) ->
|
attributes = overleaf: history: id: history?.overleaf_id
|
||||||
|
ProjectCreationHandler._createBlankProject owner_id, projectName, attributes, (error, project) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
AnalyticsManger.recordEvent(
|
AnalyticsManger.recordEvent(
|
||||||
owner_id, 'project-created', { projectId: project._id }
|
owner_id, 'project-created', { projectId: project._id }
|
||||||
)
|
)
|
||||||
callback(error, project)
|
callback(error, project)
|
||||||
|
|
||||||
_createBlankProject : (owner_id, projectName, projectHistoryId, callback = (error, project) ->)->
|
_createBlankProject : (owner_id, projectName, attributes, callback = (error, project) ->)->
|
||||||
rootFolder = new Folder {'name':'rootFolder'}
|
rootFolder = new Folder {'name':'rootFolder'}
|
||||||
project = new Project
|
|
||||||
owner_ref : new ObjectId(owner_id)
|
attributes.owner_ref = new ObjectId(owner_id)
|
||||||
name : projectName
|
attributes.name = projectName
|
||||||
project.overleaf.history.id = projectHistoryId
|
project = new Project attributes
|
||||||
|
|
||||||
|
Object.assign(project, attributes)
|
||||||
|
|
||||||
if Settings.apis?.project_history?.displayHistoryForNewProjects
|
if Settings.apis?.project_history?.displayHistoryForNewProjects
|
||||||
project.overleaf.history.display = true
|
project.overleaf.history.display = true
|
||||||
if Settings.currentImageName?
|
if Settings.currentImageName?
|
||||||
|
|
|
@ -98,7 +98,11 @@ describe 'ProjectCreationHandler', ->
|
||||||
|
|
||||||
it "should set the overleaf id if overleaf id provided", (done)->
|
it "should set the overleaf id if overleaf id provided", (done)->
|
||||||
overleaf_id = 2345
|
overleaf_id = 2345
|
||||||
@handler.createBlankProject ownerId, projectName, overleaf_id, (err, project)->
|
attributes =
|
||||||
|
overleaf:
|
||||||
|
history:
|
||||||
|
id: overleaf_id
|
||||||
|
@handler.createBlankProject ownerId, projectName, attributes, (err, project)->
|
||||||
project.overleaf.history.id.should.equal overleaf_id
|
project.overleaf.history.id.should.equal overleaf_id
|
||||||
done()
|
done()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue