2018-03-23 12:30:48 -04: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 06:05:47 -04:00
|
|
|
export_params = {
|
|
|
|
project_id: project_id,
|
|
|
|
brand_variation_id: brand_variation_id,
|
|
|
|
user_id: user_id
|
|
|
|
}
|
|
|
|
|
2018-09-13 07:14:06 -04:00
|
|
|
if req.body
|
2018-09-14 05:14:12 -04:00
|
|
|
export_params.first_name = req.body.firstName.trim() if req.body.firstName
|
|
|
|
export_params.last_name = req.body.lastName.trim() if req.body.lastName
|
|
|
|
# additional parameters for gallery exports
|
2018-09-13 07:14:06 -04:00
|
|
|
export_params.title = req.body.title.trim() if req.body.title
|
|
|
|
export_params.description = req.body.description.trim() if req.body.description
|
|
|
|
export_params.author = req.body.author.trim() if req.body.author
|
|
|
|
export_params.license = req.body.license.trim() if req.body.license
|
|
|
|
export_params.show_source = req.body.show_source if req.body.show_source
|
2018-06-04 06:05:47 -04:00
|
|
|
|
|
|
|
ExportsHandler.exportProject export_params, (err, export_data) ->
|
2018-09-18 05:05:35 -04:00
|
|
|
return err if err?
|
2018-09-13 07:14:06 -04:00
|
|
|
logger.log
|
2018-03-23 12:30:48 -04:00
|
|
|
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 07:02:23 -04:00
|
|
|
exportStatus: (req, res) ->
|
|
|
|
{export_id} = req.params
|
|
|
|
ExportsHandler.fetchExport export_id, (err, export_json) ->
|
2018-09-18 05:05:35 -04:00
|
|
|
return err if err?
|
2018-06-09 07:02:23 -04:00
|
|
|
parsed_export = JSON.parse(export_json)
|
|
|
|
json = {
|
|
|
|
status_summary: parsed_export.status_summary,
|
2018-09-18 05:05:35 -04:00
|
|
|
status_detail: parsed_export.status_detail,
|
|
|
|
partner_submission_id: parsed_export.partner_submission_id,
|
|
|
|
token: parsed_export.token
|
2018-06-09 07:02:23 -04:00
|
|
|
}
|
|
|
|
res.send export_json: json
|
2018-07-30 14:14:59 -04:00
|
|
|
|
2018-09-27 11:11:11 -04:00
|
|
|
exportDownload: (req, res) ->
|
|
|
|
{type, export_id} = req.params
|
|
|
|
|
2018-07-31 07:43:39 -04:00
|
|
|
AuthenticationController.getLoggedInUserId(req)
|
2018-09-27 11:11:11 -04:00
|
|
|
ExportsHandler.fetchDownload export_id, type, (err, export_file_url) ->
|
2018-07-30 14:14:59 -04:00
|
|
|
return err if err?
|
|
|
|
|
2018-09-27 11:11:11 -04:00
|
|
|
res.redirect export_file_url
|