Comparing version 0.5.12 to 0.5.13
@@ -12,2 +12,3 @@ var mongoose = require('mongoose'); | ||
var logWrapper = require('./common/logWrapper'); | ||
var deleteAppReferences = require('./impl/deleteAppRefrences.js'); | ||
@@ -550,4 +551,7 @@ var forms = { | ||
deleteAppRefrences: function (options, params, cb) { | ||
console.log("called delete app refrences "); | ||
cb(); | ||
var self = this; | ||
self.initConnection(options, function(err, connections) { | ||
if(err) return cb(err); | ||
return deleteAppReferences.deleteAppRefrences(connections, options, params, cb); | ||
}); | ||
}, | ||
@@ -566,4 +570,4 @@ | ||
logWrapper.addLoggingToFunctions(forms, "forms.", ["setLogger"]); | ||
logWrapper.addLoggingToFunctions(forms, "forms.", ["deleteAppRefrences", "setLogger"]); | ||
module.exports = forms; |
@@ -8,3 +8,2 @@ var models = require('../common/models.js')(); | ||
module.exports = function () { | ||
logger.debug("returning appConfig"); | ||
return { | ||
@@ -11,0 +10,0 @@ updateAppConfig: updateAppConfig, |
@@ -7,4 +7,50 @@ var util = require('util'); | ||
module.exports = function (connections, options, cb) { | ||
module.exports = function () { | ||
return { | ||
deleteAppRefrences: function (connections, options, params, cb) { | ||
}; | ||
async.series([validateParams, validateGroupAccessToForm, deleteAppForms], cb); | ||
function validateParams(cb){ | ||
var paramsValidator = validate(params); | ||
paramsValidator.has("appId", function(failure){ | ||
if(failure){ | ||
return cb(new Error("Invalid params to deleteAppReferences. No AppId specified.")); | ||
} else { | ||
return cb(); | ||
} | ||
}); | ||
} | ||
function validateGroupAccessToForm(cb) { | ||
return groups.validateAppAllowedForUser(connections, options.restrictToUser, params.appId, cb); | ||
} | ||
// updates to AppForms sub collection | ||
function deleteAppForms(cb) { | ||
var appId = params.appId; | ||
async.series([ | ||
function (cb) { // first remove the form itself | ||
var appFormsModel = models.get(connections.mongooseConnection, models.MODELNAMES.APP_FORMS); | ||
appFormsModel.find({appId: appId}).remove().exec(cb); | ||
}, | ||
function (cb) { // remove deleted from from any groups | ||
groups.removeAppFromAllGroups(connections, appId, cb); | ||
}, | ||
function deleteThemeRefrences (cb){ | ||
var appThemeModel = models.get(connections.mongooseConnection, models.MODELNAMES.APP_THEMES); | ||
appThemeModel.find({"appId":appId}).remove().exec(cb); | ||
} | ||
// , | ||
// function (cb) { // remove submissions | ||
// deleteSubmissions(formId, cb); | ||
// } | ||
], function (err) { | ||
if (err) return cb(err); | ||
return cb(null); | ||
}); | ||
} | ||
} | ||
}; | ||
}(); |
{ | ||
"name": "fh-forms", | ||
"version": "0.5.12", | ||
"version": "0.5.13", | ||
"description": "Cloud Forms API for form submission", | ||
@@ -5,0 +5,0 @@ "main": "lib/forms.js", |
@@ -1,1 +0,1 @@ | ||
0.5.12-46 | ||
0.5.13-47 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
281553
7394