fixed deleting materials
This commit is contained in:
parent
b59b3ea9ea
commit
8f88023da2
@ -122,7 +122,8 @@ router.delete('/material/' + IdValidate.parameter(), (req, res, next) => {
|
||||
if (!req.auth(res, ['write', 'dev', 'admin'], 'basic')) return;
|
||||
|
||||
// check if there are still samples referencing this material
|
||||
SampleModel.find({'material_id': new mongoose.Types.ObjectId(req.params.id)}).lean().exec((err, data) => {
|
||||
SampleModel.find({'material_id': new mongoose.Types.ObjectId(req.params.id), status: {$ne: globals.status.del}})
|
||||
.lean().exec((err, data) => {
|
||||
if (err) return next(err);
|
||||
if (data.length) {
|
||||
return res.status(400).json({status: 'Material still in use'});
|
||||
|
Reference in New Issue
Block a user