elderwand 0.1.60 → 0.1.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@
9
9
  var path = require('path');
10
10
  //var utils = rekuire('/lib/utils');
11
11
  var extend = require('util')._extend;
12
-
12
+ var ObjectId = require('mongoose').Types.ObjectId
13
13
  var viewsDir = 'app/views/'
14
14
  module.exports.getChildControllers = function(){
15
15
  return childControllers;
@@ -26,30 +26,34 @@ module.exports.inherit = function (child) {
26
26
  child.coveredMethods = [];
27
27
  child.coveredMethods.push("load");
28
28
  child.load = function (req, res, next, id) {
29
- child.model.load(id, function (err, model) {
30
- if (err){
31
- res.errors.push(err)
32
- res.statusData = "Error";
33
- return next(err);
34
- }
35
- if (!model){
36
- res.statusData = "Error"
37
- return next(new Error('not found'));
38
- }
39
- if (!model.canSeeByUser(req.user)) {
40
- //req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
41
- if(req.user){
42
- res.statusData = "Error"
43
- return res.redirect('/users/' + req.user.id);
44
- }else{
45
- res.statusData = "Error"
46
- return res.redirect('/login');
47
- }
48
- return;
49
- }
50
- req[child.singularName] = model;
51
- next();
52
- });
29
+ if(ObjectId.isValid(id)){
30
+ child.model.load(id, function (err, model) {
31
+ if (err){
32
+ res.errors.push(err)
33
+ res.statusData = "Error";
34
+ return next(err);
35
+ }
36
+ if (!model){
37
+ res.statusData = "Error"
38
+ return next(new Error('not found'));
39
+ }
40
+ if (!model.canSeeByUser(req.user)) {
41
+ //req.flash('info', 'Bu işlemi yapmak için yetkiniz yok');
42
+ if(req.user){
43
+ res.statusData = "Error"
44
+ return res.redirect('/users/' + req.user.id);
45
+ }else{
46
+ res.statusData = "Error"
47
+ return res.redirect('/login');
48
+ }
49
+ return;
50
+ }
51
+ req[child.singularName] = model;
52
+ next();
53
+ });
54
+ }else{
55
+ next()
56
+ }
53
57
  };
54
58
 
55
59
 
@@ -197,6 +197,22 @@ module.exports = function(){
197
197
  }
198
198
  return obj;
199
199
  });
200
+ addPropertyToClass(Array.prototype,"group", function(array, blend, keyFunc){
201
+ var obj = {};
202
+ for(var i = 0; i < this.length; i++){
203
+ var item = this[i];
204
+ var key = keyFunc(this[i], i);
205
+ if(item && key && !obj[key]){
206
+ obj[key] = []
207
+ }
208
+
209
+ if(item && key){
210
+ obj[key].push(item);
211
+ }
212
+
213
+ }
214
+ return obj;
215
+ });
200
216
  addPropertyToClass(Array.prototype,"notIn", function(array, comp){
201
217
  var arr = [];
202
218
  for(var i = 0; i < this.length; i++){
package/dump.rdb ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elderwand",
3
- "version": "0.1.60",
3
+ "version": "0.1.62",
4
4
  "description": "Mamtas Technology Internal Framework",
5
5
  "main": "./node_modules/.bin/nodemon index.js",
6
6
  "scripts": {