fixing grant deletion
This commit is contained in:
@@ -61,14 +61,16 @@ exports.findByDonorId = (req, res, next) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.delete = (req, res, next) => {
|
exports.delete = (req, res, next) => {
|
||||||
const grant_id = req.params.grant_id;
|
const { grant_id } = req.body;
|
||||||
|
const user = req.user;
|
||||||
|
|
||||||
Grant.destroy({ where: { id: grant_id } })
|
Grant.destroy({ where: { id: grant_id, donor_id: user.id } })
|
||||||
.then(result => {
|
.then(result => {
|
||||||
var message = 'Already Deleted';
|
var message = 'Already Deleted';
|
||||||
if (result) {
|
if (result) {
|
||||||
message = 'Grant Deleted';
|
message = 'Grant Deleted';
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(201).json({
|
res.status(201).json({
|
||||||
result,
|
result,
|
||||||
message
|
message
|
||||||
|
|||||||
@@ -23,11 +23,7 @@ router.get('/grants/', checkAuth(roles.DONOR), controllers.grant.findByDonorId);
|
|||||||
router.post('/grants/', checkAuth(roles.DONOR), controllers.grant.create);
|
router.post('/grants/', checkAuth(roles.DONOR), controllers.grant.create);
|
||||||
|
|
||||||
// DELECT a grant of a donor
|
// DELECT a grant of a donor
|
||||||
router.delete(
|
router.delete('/grants/', checkAuth(roles.DONOR), controllers.grant.delete);
|
||||||
'/grants/:grant_id',
|
|
||||||
checkAuth(roles.DONOR),
|
|
||||||
controllers.grant.delete
|
|
||||||
);
|
|
||||||
|
|
||||||
// POST to get suggested organizations to distribute to
|
// POST to get suggested organizations to distribute to
|
||||||
// running "the algorithm"
|
// running "the algorithm"
|
||||||
|
|||||||
Reference in New Issue
Block a user