Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
KSZK
DevTeam
kszkepzes
Backend
Commits
2d0afcde
Commit
2d0afcde
authored
Jul 29, 2020
by
rlacko
💬
Browse files
update activity
parent
f7c3c401
Pipeline
#4663
passed with stages
in 1 minute and 36 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/resources/activity/activityControllers.js
View file @
2d0afcde
...
...
@@ -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
})
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment