2016-12-09 10:43:08 -05:00
|
|
|
RangesManager = require "./RangesManager"
|
|
|
|
logger = require "logger-sharelatex"
|
2017-01-06 07:41:58 -05:00
|
|
|
UserInfoController = require "../User/UserInfoController"
|
2017-01-09 09:25:27 -05:00
|
|
|
DocumentUpdaterHandler = require "../DocumentUpdater/DocumentUpdaterHandler"
|
2016-12-09 10:43:08 -05:00
|
|
|
|
|
|
|
module.exports = RangesController =
|
|
|
|
getAllRanges: (req, res, next) ->
|
|
|
|
project_id = req.params.project_id
|
|
|
|
logger.log {project_id}, "request for project ranges"
|
|
|
|
RangesManager.getAllRanges project_id, (error, docs = []) ->
|
|
|
|
return next(error) if error?
|
|
|
|
docs = ({id: d._id, ranges: d.ranges} for d in docs)
|
|
|
|
res.json docs
|
2017-01-06 07:41:58 -05:00
|
|
|
|
|
|
|
getAllRangesUsers: (req, res, next) ->
|
|
|
|
project_id = req.params.project_id
|
|
|
|
logger.log {project_id}, "request for project range users"
|
|
|
|
RangesManager.getAllRangesUsers project_id, (error, users) ->
|
|
|
|
return next(error) if error?
|
|
|
|
users = (UserInfoController.formatPersonalInfo(user) for user in users)
|
|
|
|
res.json users
|
2017-01-09 09:25:27 -05:00
|
|
|
|
|
|
|
acceptChange: (req, res, next) ->
|
|
|
|
{project_id, doc_id, change_id} = req.params
|
|
|
|
logger.log {project_id, doc_id, change_id}, "request to accept change"
|
|
|
|
DocumentUpdaterHandler.acceptChange project_id, doc_id, change_id, (error) ->
|
|
|
|
return next(error) if error?
|
|
|
|
res.send 204
|