From c740686ab0bc5f4fa987a9bde743e156b0d0262d Mon Sep 17 00:00:00 2001 From: arnaucode Date: Fri, 22 Sep 2017 19:21:32 +0200 Subject: [PATCH] moving and renaming --- .gitignore | 0 LICENSE | 0 README.md | 12 ++++----- adminConfig.js | 0 config.js | 0 controllers/adminController.js | 44 ++++++++++++++++++++++++++++++--- controllers/searchController.js | 0 controllers/travelController.js | 0 controllers/userController.js | 0 models/adminModel.js | 0 models/commentModel.js | 0 models/notificationModel.js | 0 models/travelModel.js | 0 models/userModel.js | 0 package.json | 0 server.js | 3 +++ testSendImage.js | 0 tests.js | 0 tests/config.json | 0 tests/main.go | 0 tests/readConfig.go | 0 tests/requests.go | 0 tests/users.json | 0 23 files changed, 49 insertions(+), 10 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md mode change 100644 => 100755 adminConfig.js mode change 100644 => 100755 config.js mode change 100644 => 100755 controllers/adminController.js mode change 100644 => 100755 controllers/searchController.js mode change 100644 => 100755 controllers/travelController.js mode change 100644 => 100755 controllers/userController.js mode change 100644 => 100755 models/adminModel.js mode change 100644 => 100755 models/commentModel.js mode change 100644 => 100755 models/notificationModel.js mode change 100644 => 100755 models/travelModel.js mode change 100644 => 100755 models/userModel.js mode change 100644 => 100755 package.json mode change 100644 => 100755 testSendImage.js mode change 100644 => 100755 tests.js mode change 100644 => 100755 tests/config.json mode change 100644 => 100755 tests/main.go mode change 100644 => 100755 tests/readConfig.go mode change 100644 => 100755 tests/requests.go mode change 100644 => 100755 tests/users.json diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 index d1fe571..8697317 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# CarsInCommonServer +# commonroutesServer -- server code: https://github.com/arnaucode/carsincommonServer -- frontend app code: https://github.com/arnaucode/carsincommonApp +- server code: https://github.com/arnaucode/commonroutesServer +- frontend app code: https://github.com/arnaucode/commonroutesApp - images server: https://github.com/arnaucode/goImgServer -- admin web: https://github.com/arnaucode/carsincommonAdminWeb +- admin web: https://github.com/arnaucode/commonroutesAdminWeb **Backend:** @@ -18,8 +18,8 @@ App: -![carsincommon](https://raw.githubusercontent.com/arnaucode/carsincommonApp/master/carsincommon.png "carsincommon") -code: https://github.com/arnaucode/carsincommonApp +![commonroutes](https://raw.githubusercontent.com/arnaucode/commonroutesApp/master/commonroutes.png "commonroutes") +code: https://github.com/arnaucode/commonroutesApp -------------------- diff --git a/adminConfig.js b/adminConfig.js old mode 100644 new mode 100755 diff --git a/config.js b/config.js old mode 100644 new mode 100755 diff --git a/controllers/adminController.js b/controllers/adminController.js old mode 100644 new mode 100755 index 56f312a..dcbb485 --- a/controllers/adminController.js +++ b/controllers/adminController.js @@ -113,6 +113,15 @@ exports.login = function(req, res) { }); }; +exports.getAllAdmins = function(req, res) { + adminModel.find() + .limit(pageSize) + .skip(pageSize * Number(req.query.page)) + .exec(function(err, admins) { + if (err) return res.send(500, err.message); + res.status(200).jsonp(admins); + }); +}; exports.changePassword = function(req, res) { //if(req.body.) userModel.update({ @@ -534,9 +543,22 @@ exports.validateUser = function(req, res) { user.validated = true; user.validatedBy = admin._id; - user.save(function(err, user) { + var notification = new notificationModel({ + concept: "admin", + message: "an admin has validated your account", + date: new Date(), + icon: 'admin', + link: "users/" + user._id, + user: user._id + }); + notification.save(function(err, notification) { if (err) return res.send(500, err.message); - userController.getUserById(req, res); + + user.notifications.push(notification._id); + user.save(function(err, user) { + if (err) return res.send(500, err.message); + userController.getUserById(req, res); + }); }); }); } @@ -563,10 +585,24 @@ exports.unvalidateUser = function(req, res) { user.validated = false; user.validatedBy = admin._id; - user.save(function(err, user) { + var notification = new notificationModel({ + concept: "admin", + message: "an admin has unvalidated your account", + date: new Date(), + icon: 'admin', + link: "users/" + user._id, + user: user._id + }); + notification.save(function(err, notification) { if (err) return res.send(500, err.message); - userController.getUserById(req, res); + + user.notifications.push(notification._id); + user.save(function(err, user) { + if (err) return res.send(500, err.message); + userController.getUserById(req, res); + }); }); + }); } }); diff --git a/controllers/searchController.js b/controllers/searchController.js old mode 100644 new mode 100755 diff --git a/controllers/travelController.js b/controllers/travelController.js old mode 100644 new mode 100755 diff --git a/controllers/userController.js b/controllers/userController.js old mode 100644 new mode 100755 diff --git a/models/adminModel.js b/models/adminModel.js old mode 100644 new mode 100755 diff --git a/models/commentModel.js b/models/commentModel.js old mode 100644 new mode 100755 diff --git a/models/notificationModel.js b/models/notificationModel.js old mode 100644 new mode 100755 diff --git a/models/travelModel.js b/models/travelModel.js old mode 100644 new mode 100755 diff --git a/models/userModel.js b/models/userModel.js old mode 100644 new mode 100755 diff --git a/package.json b/package.json old mode 100644 new mode 100755 diff --git a/server.js b/server.js index d7177b8..76f7c13 100755 --- a/server.js +++ b/server.js @@ -118,6 +118,9 @@ apiRoutes.use(function(req, res, next) { }); //fi verificació de token //admin + +apiRoutes.route('/admins') + .get(adminCtrl.getAllAdmins); apiRoutes.route('/admin/network') .get(adminCtrl.network); apiRoutes.route('/admin/user/network/:userid') diff --git a/testSendImage.js b/testSendImage.js old mode 100644 new mode 100755 diff --git a/tests.js b/tests.js old mode 100644 new mode 100755 diff --git a/tests/config.json b/tests/config.json old mode 100644 new mode 100755 diff --git a/tests/main.go b/tests/main.go old mode 100644 new mode 100755 diff --git a/tests/readConfig.go b/tests/readConfig.go old mode 100644 new mode 100755 diff --git a/tests/requests.go b/tests/requests.go old mode 100644 new mode 100755 diff --git a/tests/users.json b/tests/users.json old mode 100644 new mode 100755