2014-02-12 05:23:40 -05:00
|
|
|
module.exports =
|
|
|
|
user: (user) ->
|
2016-10-25 10:50:05 -04:00
|
|
|
if !user?
|
|
|
|
return null
|
2014-02-12 05:23:40 -05:00
|
|
|
if !user._id?
|
|
|
|
user = {_id : user}
|
|
|
|
return {
|
|
|
|
id: user._id
|
|
|
|
email: user.email
|
|
|
|
first_name: user.name
|
|
|
|
last_name: user.name
|
|
|
|
}
|
2018-03-09 06:05:17 -05:00
|
|
|
|
2014-02-12 05:23:40 -05:00
|
|
|
project: (project) ->
|
2016-10-25 10:50:05 -04:00
|
|
|
if !project?
|
|
|
|
return null
|
2014-02-12 05:23:40 -05:00
|
|
|
if !project._id?
|
|
|
|
project = {_id: project}
|
|
|
|
return {
|
|
|
|
id: project._id
|
|
|
|
name: project.name
|
|
|
|
}
|
2018-03-09 06:05:17 -05:00
|
|
|
|
|
|
|
docs: (docs) ->
|
2018-03-27 09:41:56 -04:00
|
|
|
if !docs?.map?
|
|
|
|
return
|
2018-03-27 09:45:47 -04:00
|
|
|
docs.map (doc) ->
|
2018-03-09 06:05:17 -05:00
|
|
|
{
|
|
|
|
path: doc.path
|
|
|
|
id: doc.doc
|
|
|
|
}
|
|
|
|
|
|
|
|
files: (files) ->
|
2018-03-27 09:41:56 -04:00
|
|
|
if !files?.map?
|
|
|
|
return
|
2018-03-27 09:45:47 -04:00
|
|
|
files.map (file) ->
|
2018-03-09 06:05:17 -05:00
|
|
|
{
|
|
|
|
path: file.path
|
|
|
|
id: file.file
|
|
|
|
}
|