2018-09-25 09:10:06 -04:00
|
|
|
AuthenticationController = require('../Authentication/AuthenticationController')
|
|
|
|
UserMembershipController = require './UserMembershipController'
|
|
|
|
|
|
|
|
module.exports =
|
|
|
|
apply: (webRouter) ->
|
2018-10-11 13:56:14 -04:00
|
|
|
webRouter.get '/manage/groups/:id/members',
|
2018-09-25 09:10:06 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
(req, res, next) -> UserMembershipController.index('group', req, res, next)
|
|
|
|
|
|
|
|
|
|
|
|
regularEntitites =
|
2018-10-11 13:56:14 -04:00
|
|
|
groups: 'groupManagers'
|
|
|
|
institutions: 'institution'
|
2018-09-25 09:10:06 -04:00
|
|
|
for pathName, entityName of regularEntitites
|
|
|
|
do (pathName, entityName) ->
|
2018-10-11 13:56:14 -04:00
|
|
|
webRouter.get "/manage/#{pathName}/:id/managers",
|
2018-09-25 09:10:06 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
(req, res, next) -> UserMembershipController.index(entityName, req, res, next)
|
|
|
|
|
2018-10-11 13:56:14 -04:00
|
|
|
webRouter.post "/manage/#{pathName}/:id/managers",
|
2018-09-25 09:10:06 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
(req, res, next) -> UserMembershipController.add(entityName, req, res, next)
|
|
|
|
|
2018-10-11 13:56:14 -04:00
|
|
|
webRouter.delete "/manage/#{pathName}/:id/managers/:userId",
|
2018-09-25 09:10:06 -04:00
|
|
|
AuthenticationController.requireLogin(),
|
|
|
|
(req, res, next) -> UserMembershipController.remove(entityName, req, res, next)
|