Skip to content

Commit

Permalink
Merge pull request #3275 from LiteFarmOrg/LF-3884-an-error-message-is…
Browse files Browse the repository at this point in the history
…-displayed-once-the-user-tries-to-create-a-task-for-a-wild-crop-any-task

LF-3884 check if location exists in request body
  • Loading branch information
SayakaOno authored Jun 26, 2024
2 parents 34e0a13 + 2e45182 commit b2839e3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/api/src/controllers/taskController.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,14 @@ const taskController = {
return async (req, res, next) => {
try {
// Do not allow to create a task if location is deleted
const locations = req.body.locations;
if (
await baseController.isDeleted(null, Location, {
[Location.idColumn]: req.body.locations[0]?.location_id,
})
) {
locations?.length &&
(await baseController.isDeleted(null, Location, {
[Location.idColumn]: locations[0].location_id,
}))
)
return res.status(409).send('location deleted');
}

// OC: the "noInsert" rule will not fail if a relationship is present in the graph.
// it will just ignore the insert on it. This is just a 2nd layer of protection
Expand Down

0 comments on commit b2839e3

Please sign in to comment.