Avoid snake_case notation
This commit is contained in:
@@ -101,9 +101,9 @@ NamedMapsAdminController.prototype.checkContentType = function (action, label) {
|
||||
NamedMapsAdminController.prototype.create = function () {
|
||||
return function createTemplateMiddleware (req, res, next) {
|
||||
const cdbuser = res.locals.user;
|
||||
const cfg = req.body;
|
||||
const template = req.body;
|
||||
|
||||
this.templateMaps.addTemplate(cdbuser, cfg, (err, tpl_id) => {
|
||||
this.templateMaps.addTemplate(cdbuser, template, (err, templateId) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@@ -111,18 +111,18 @@ NamedMapsAdminController.prototype.create = function () {
|
||||
res.status(200);
|
||||
|
||||
const method = req.query.callback ? 'jsonp' : 'json';
|
||||
res[method]({ template_id: tpl_id });
|
||||
res[method]({ template_id: templateId });
|
||||
});
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
NamedMapsAdminController.prototype.update = function () {
|
||||
return function updateTemplateMiddleware (req, res, next) {
|
||||
const cdbuser = res.locals.user;
|
||||
const { user } = res.locals;
|
||||
const template = req.body;
|
||||
const tpl_id = templateName(req.params.template_id);
|
||||
const templateId = templateName(req.params.template_id);
|
||||
|
||||
this.templateMaps.updTemplate(cdbuser, tpl_id, template, (err) => {
|
||||
this.templateMaps.updTemplate(user, templateId, template, (err) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ NamedMapsAdminController.prototype.update = function () {
|
||||
res.status(200);
|
||||
|
||||
const method = req.query.callback ? 'jsonp' : 'json';
|
||||
res[method]({ template_id: tpl_id });
|
||||
res[method]({ template_id: templateId });
|
||||
});
|
||||
}.bind(this);
|
||||
};
|
||||
@@ -140,26 +140,26 @@ NamedMapsAdminController.prototype.retrieve = function () {
|
||||
req.profiler.start('windshaft-cartodb.get_template');
|
||||
|
||||
const cdbuser = res.locals.user;
|
||||
const tpl_id = templateName(req.params.template_id);
|
||||
const templateId = templateName(req.params.template_id);
|
||||
|
||||
this.templateMaps.getTemplate(cdbuser, tpl_id, (err, tpl_val) => {
|
||||
this.templateMaps.getTemplate(cdbuser, templateId, (err, template) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (!tpl_val) {
|
||||
const error = new Error(`Cannot find template '${tpl_id}' of user '${cdbuser}'`);
|
||||
if (!template) {
|
||||
const error = new Error(`Cannot find template '${templateId}' of user '${cdbuser}'`);
|
||||
error.http_status = 404;
|
||||
return next(error);
|
||||
}
|
||||
// auth_id was added by ourselves,
|
||||
// so we remove it before returning to the user
|
||||
delete tpl_val.auth_id;
|
||||
delete template.auth_id;
|
||||
|
||||
res.status(200);
|
||||
|
||||
const method = req.query.callback ? 'jsonp' : 'json';
|
||||
res[method]({ template: tpl_val });
|
||||
res[method]({ template });
|
||||
});
|
||||
}.bind(this);
|
||||
};
|
||||
@@ -168,10 +168,10 @@ NamedMapsAdminController.prototype.destroy = function () {
|
||||
return function destroyTemplateMiddleware (req, res, next) {
|
||||
req.profiler.start('windshaft-cartodb.delete_template');
|
||||
|
||||
const cdbuser = res.locals.user;
|
||||
const tpl_id = templateName(req.params.template_id);
|
||||
const { user } = res.locals;
|
||||
const templateId = templateName(req.params.template_id);
|
||||
|
||||
this.templateMaps.delTemplate(cdbuser, tpl_id, (err/*, tpl_val*/) => {
|
||||
this.templateMaps.delTemplate(user, templateId, (err/* , tpl_val */) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@@ -188,9 +188,9 @@ NamedMapsAdminController.prototype.list = function () {
|
||||
return function listTemplatesMiddleware (req, res, next) {
|
||||
req.profiler.start('windshaft-cartodb.get_template_list');
|
||||
|
||||
const cdbuser = res.locals.user;
|
||||
const { user } = res.locals;
|
||||
|
||||
this.templateMaps.listTemplates(cdbuser, (err, tpl_ids) => {
|
||||
this.templateMaps.listTemplates(user, (err, templateIds) => {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@@ -198,7 +198,7 @@ NamedMapsAdminController.prototype.list = function () {
|
||||
res.status(200);
|
||||
|
||||
const method = req.query.callback ? 'jsonp' : 'json';
|
||||
res[method]({ template_ids: tpl_ids });
|
||||
res[method]({ template_ids: templateIds });
|
||||
});
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user