Project e Todos sistemati...
aggiunti Gruppi
This commit is contained in:
@@ -47,6 +47,9 @@ router.post('/', authenticate, (req, res) => {
|
||||
.then(record => {
|
||||
// tools.mylog('REC SAVED :', record.descr);
|
||||
|
||||
res.send({ record });
|
||||
|
||||
/*
|
||||
tools.sendNotificationToUser(project.userId, 'Project: ' + record.descr, record.descr, '/project/' + project.category, '', 'project', [])
|
||||
.then(ris => {
|
||||
if (ris) {
|
||||
@@ -55,6 +58,8 @@ router.post('/', authenticate, (req, res) => {
|
||||
// already sent the error on calling sendNotificationToUser
|
||||
}
|
||||
})
|
||||
|
||||
*/
|
||||
})
|
||||
}).catch((e) => {
|
||||
console.log('ERRORE in PROJECT POST', e.message);
|
||||
@@ -119,8 +124,9 @@ router.patch('/:id', authenticate, (req, res) => {
|
||||
|
||||
router.get('/', (req, res) => {
|
||||
tools.mylog('GET ALL PROJECTS: ');
|
||||
const idapp = req.query.idapp;
|
||||
|
||||
return Project.getAllProjects('').then((objprojects) => {
|
||||
return Project.getAllProjects('', idapp).then((objprojects) => {
|
||||
if (!!objprojects.arrproj)
|
||||
tools.mylog('projects', objprojects.arrproj.length);
|
||||
|
||||
@@ -135,6 +141,7 @@ router.get('/', (req, res) => {
|
||||
|
||||
router.get('/:userId', authenticate, (req, res) => {
|
||||
const userId = req.params.userId;
|
||||
const idapp = req.query.idapp;
|
||||
|
||||
tools.mylog('GET PROJECTS : ', req.params);
|
||||
|
||||
@@ -148,7 +155,7 @@ router.get('/:userId', authenticate, (req, res) => {
|
||||
}
|
||||
|
||||
// Extract all the projects of the userId only
|
||||
return Project.getAllProjects(userId).then((objprojects) => {
|
||||
return Project.getAllProjects(userId, idapp).then((objprojects) => {
|
||||
if (!!objprojects.arrproj)
|
||||
tools.mylog('projects', objprojects.arrproj.length);
|
||||
|
||||
@@ -202,21 +209,36 @@ async function calcSingleProject(userId, myproj) {
|
||||
router.delete('/:id', authenticate, (req, res) => {
|
||||
var id = req.params.id;
|
||||
|
||||
let hide = true;
|
||||
|
||||
if (!ObjectID.isValid(id)) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
|
||||
Project.findByIdAndRemove(id).then((project) => {
|
||||
if (!project) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
if (hide) {
|
||||
Project.findByIdAndUpdate(id, { $set: { deleted: true } }).then((project) => {
|
||||
if (!project) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
res.send({ project });
|
||||
}).catch((e) => {
|
||||
res.status(400).send();
|
||||
});
|
||||
|
||||
tools.mylog('DELETED ', project.descr, project._id);
|
||||
} else {
|
||||
|
||||
res.send({ project });
|
||||
}).catch((e) => {
|
||||
res.status(400).send();
|
||||
});
|
||||
Project.findByIdAndRemove(id).then((project) => {
|
||||
if (!project) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
|
||||
tools.mylog('DELETED ', project.descr, project._id);
|
||||
|
||||
res.send({ project });
|
||||
}).catch((e) => {
|
||||
res.status(400).send();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user