2018-03-23 16:30:48 +00:00
|
|
|
ExportsHandler = require("./ExportsHandler")
|
|
|
|
AuthenticationController = require("../Authentication/AuthenticationController")
|
|
|
|
logger = require("logger-sharelatex")
|
|
|
|
|
|
|
|
module.exports =
|
|
|
|
|
|
|
|
exportProject: (req, res) ->
|
|
|
|
{project_id, brand_variation_id} = req.params
|
|
|
|
user_id = AuthenticationController.getLoggedInUserId(req)
|
2018-06-04 10:05:47 +00:00
|
|
|
export_params = {
|
|
|
|
project_id: project_id,
|
|
|
|
brand_variation_id: brand_variation_id,
|
|
|
|
user_id: user_id
|
|
|
|
}
|
|
|
|
|
2018-06-07 11:57:01 +00:00
|
|
|
if req.body && req.body.firstName && req.body.lastName
|
2018-06-04 10:11:40 +00:00
|
|
|
export_params.first_name = req.body.firstName.trim()
|
|
|
|
export_params.last_name = req.body.lastName.trim()
|
2018-06-04 10:05:47 +00:00
|
|
|
|
|
|
|
ExportsHandler.exportProject export_params, (err, export_data) ->
|
2018-05-18 14:08:33 +00:00
|
|
|
return next(err) if err?
|
2018-03-23 16:30:48 +00:00
|
|
|
logger.log
|
|
|
|
user_id:user_id
|
|
|
|
project_id: project_id
|
|
|
|
brand_variation_id:brand_variation_id
|
|
|
|
export_v1_id:export_data.v1_id
|
|
|
|
"exported project"
|
|
|
|
res.send export_v1_id: export_data.v1_id
|
|
|
|
|
2018-06-09 11:02:23 +00:00
|
|
|
exportStatus: (req, res) ->
|
|
|
|
{export_id} = req.params
|
|
|
|
ExportsHandler.fetchExport export_id, (err, export_json) ->
|
|
|
|
return next(err) if err?
|
|
|
|
parsed_export = JSON.parse(export_json)
|
|
|
|
json = {
|
|
|
|
status_summary: parsed_export.status_summary,
|
|
|
|
status_detail: parsed_export.status_detail
|
|
|
|
}
|
|
|
|
res.send export_json: json
|