Read brand variation id from v1-crafted links; set brand variation id for projects created from v1 templates.

This commit is contained in:
Paulo Reis 2018-10-09 11:18:55 +01:00
parent a380feab98
commit 29787c42c5
3 changed files with 33 additions and 9 deletions

View file

@ -46,3 +46,14 @@ module.exports =
else
logger.err project_id:project_id, languageCode:languageCode, "tryed to set unsafe language"
callback()
setBrandVariationId: (project_id, brandVariationId, callback = ()->)->
logger.log project_id:project_id, brandVariationId:brandVariationId, "setting the brand variation id"
if !brandVariationId?
return callback()
conditions = {_id:project_id}
update = {brandVariationId}
Project.update conditions, update, {}, (err)->
if err?
logger.err err:err, "error setting brandVariationId"
callback()

View file

@ -33,6 +33,7 @@ module.exports = TemplatesController =
data.name = req.query.templateName
data.compiler = ENGINE_TO_COMPILER_MAP[req.query.latexEngine]
data.mainFile = req.query.mainFile
data.brandVariationId = req.query.brandVariationId
res.render path.resolve(__dirname, "../../../views/project/editor/new_from_template"), data
createProjectFromV1Template: (req, res)->
@ -55,6 +56,7 @@ module.exports = TemplatesController =
mainFile: req.body.mainFile
templateId: req.body.templateId
templateVersionId: req.body.templateVersionId
brandVariationId: req.body.brandVariationId
image: 'wl_texlive:2018.1'
},
req,
@ -78,15 +80,16 @@ module.exports = TemplatesController =
setCompiler project._id, options.compiler, ->
setImage project._id, options.image, ->
setMainFile project._id, options.mainFile, ->
fs.unlink dumpPath, ->
delete req.session.templateData
conditions = {_id:project._id}
update = {
fromV1TemplateId:options.templateId,
fromV1TemplateVersionId:options.templateVersionId
}
Project.update conditions, update, {}, (err)->
res.redirect "/project/#{project._id}"
setBrandVariationId project._id, options.brandVariationId, ->
fs.unlink dumpPath, ->
delete req.session.templateData
conditions = {_id:project._id}
update = {
fromV1TemplateId:options.templateId,
fromV1TemplateVersionId:options.templateVersionId
}
Project.update conditions, update, {}, (err)->
res.redirect "/project/#{project._id}"
setCompiler = (project_id, compiler, callback)->
if compiler?
@ -105,3 +108,11 @@ setMainFile = (project_id, mainFile, callback) ->
ProjectRootDocManager.setRootDocFromName project_id, mainFile, callback
else
callback()
setBrandVariationId = (project_id, brandVariationId, callback) ->
logger.log brandVariationId, "brandVariationId"
if brandVariationId?
ProjectOptionsHandler.setBrandVariationId project_id, brandVariationId, callback
else
callback()

View file

@ -25,3 +25,5 @@ block content
input(type="hidden" name="templateName" value=name)
input(type="hidden" name="compiler" value=compiler)
input(type="hidden" name="mainFile" value=mainFile)
if brandVariationId
input(type="hidden" name="brandVariationId" value=brandVariationId)