Skip to content

Commit

Permalink
Merge pull request pencilblue#973 from pencilblue/0.5.1
Browse files Browse the repository at this point in the history
0.5.1
  • Loading branch information
brianhyder committed Mar 22, 2016
2 parents 2c133f6 + a3f0778 commit 5cbf8e6
Show file tree
Hide file tree
Showing 100 changed files with 2,273 additions and 1,373 deletions.
12 changes: 6 additions & 6 deletions controllers/admin/base_admin_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ module.exports = function BaseAdminControllerModule(pb) {

/**
* Centralized place to obtain the pills to be displayed on top of the admin controller
*
* @param navKey
* @param localizationService
* @param activePill
* @param data
* @method getAdminPills
* @param {string} navKey
* @param {Localization} localizationService
* @param {*} activePill
* @param {Object} [data]
* @return {Object} pill objects for admin console with site pill at the beginning
*/
BaseAdminController.prototype.getAdminPills = function (navKey, localizationService, activePill, data) {
Expand All @@ -71,4 +71,4 @@ module.exports = function BaseAdminControllerModule(pb) {
};

return BaseAdminController;
};
};
81 changes: 38 additions & 43 deletions controllers/api/api_action_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = function ApiActionControllerModule(pb) {

//pb dependencies
var BaseController = pb.BaseController;

/**
* Controller interface used to map simple actions to handlers and provide
* a flow for validation and error handling.
Expand Down Expand Up @@ -90,52 +90,47 @@ module.exports = function ApiActionControllerModule(pb) {

var actions = this.getActions();
if (!pb.validation.validateNonEmptyStr(action, true) || actions[action] === undefined) {
cb(null, [this.ls.get('VALID_ACTION_REQUIRED')]);
return;
return cb(null, [this.ls.g('generic.VALID_ACTION_REQUIRED')]);
}
else {
var self = this;
var tasks = [
function(callback) {
self.validatePathParameters(action, callback);
},
function(callback) {
self.validateQueryParameters(action, callback);
},
function(callback) {
if (self.req.method.toUpperCase() === 'POST') {
self.getPostParams(function(err, post) {
if (util.isError(err)) {
callback(err, []);
return;
}

if (self.getAutoSanitize()) {
self.sanitizeObject(post);
}

self.post = post;
self.validatePostParameters(action, post, callback);
});

var self = this;
var tasks = [
function(callback) {
self.validatePathParameters(action, callback);
},
function(callback) {
self.validateQueryParameters(action, callback);
},
function(callback) {
if (self.req.method.toUpperCase() !== 'POST') {
return callback(null, []);
}
self.getPostParams(function(err, post) {
if (util.isError(err)) {
return callback(err, []);
}
else {
callback(null, []);

if (self.getAutoSanitize()) {
self.sanitizeObject(post);
}
},
];
async.parallel(tasks, function(err, results) {

var errors = [];
if (util.isArray(results)) {
for (var i = 0; i < results.length; i++) {
if (util.isArray(results[i])) {
util.arrayPushAll(results[i], errors);
}

self.post = post;
self.validatePostParameters(action, post, callback);
});
},
];
async.parallel(tasks, function(err, results) {

var errors = [];
if (util.isArray(results)) {
for (var i = 0; i < results.length; i++) {
if (util.isArray(results[i])) {
util.arrayPushAll(results[i], errors);
}
}
cb(err, errors);
});
}
}
cb(err, errors);
});
};

/**
Expand Down Expand Up @@ -170,7 +165,7 @@ module.exports = function ApiActionControllerModule(pb) {
var errors = [];
var actions = this.getActions();
if (actions[action] && !pb.validation.validateNonEmptyStr(this.pathVars.id, true)) {
errors.push(this.ls.get('VALID_IDENTIFIER_REQUIRED'));
errors.push(this.ls.g('generic.VALID_IDENTIFIER_REQUIRED'));
}
cb(null, errors);
};
Expand Down
Loading

0 comments on commit 5cbf8e6

Please sign in to comment.