Commit 2d0afcde authored by rlacko's avatar rlacko 💬
Browse files

update activity

parent f7c3c401
Pipeline #4663 passed with stages
in 1 minute and 36 seconds
......@@ -159,7 +159,7 @@ exports.default.removeOne = async (req, res) => {
.exec()
if (!activity) {
return res.status(404).json({ message: 'Activity not found!' }).end()
return res.status(404).json({ message: 'Activity not found!' })
}
await Attendance.deleteMany({
......@@ -174,19 +174,14 @@ exports.default.removeOne = async (req, res) => {
}),
})
return res
.status(200)
.json({ data: pick(activity, pickedKeys) })
.end()
return res.status(200).json({ data: pick(activity, pickedKeys) })
} catch (err) {
console.error(err)
return res.status(500).json({ message: err.message }).end()
return res.status(500).json({ message: err.message })
}
}
//TODO req.user.role === 'mentor'
exports.default.updateOne = async (req, res) => {
//validate
try {
const activity = await Activity.findOneAndUpdate(
{ _id: req.params.id },
......@@ -195,17 +190,18 @@ exports.default.updateOne = async (req, res) => {
)
.populate({
path: 'comment',
populate: { path: 'creator', select: '-_id fullName nickName' },
select: '_id creator text createdAt',
})
.select('-_id -__v')
.select('-__v')
.lean()
.exec()
if (!activity) {
res.status(404).json({ message: 'Activity not found!' }).end()
}
res.status(200).json({ data: activity }).end
if (!activity)
return res.status(404).json({ message: 'Activity not found!' })
res.status(200).json({ data: pick(activity, pickedKeys) })
} catch (err) {
res.status(500).json({ message: err.message }).end()
console.error(err)
res.status(500).json({ message: err.message })
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment