Removed extra scope validation endpoint

pull/306/merge
Amanda Anganes 2013-03-15 09:08:06 -04:00
parent 96e333afa6
commit d24ecd2e7c
2 changed files with 9 additions and 34 deletions

View File

@ -104,23 +104,6 @@ public class ScopeAPI {
}
}
@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value="/checkScopeValue", method = RequestMethod.GET)
public String checkScopeValue(@RequestParam String value, ModelMap m) {
SystemScope alreadyExists = scopeService.getByValue(value);
if (alreadyExists != null) {
m.put("code", HttpStatus.CONFLICT);
m.put("entity", "A scope with value " + value + " already exists, please choose a different value.");
}
else {
m.put("code", HttpStatus.ACCEPTED);
m.put("entity", "OK");
}
return "jsonEntityView";
}
@PreAuthorize("hasRole('ROLE_ADMIN')")
@RequestMapping(value = "", method = RequestMethod.POST, produces = "application/json", consumes = "application/json")
public String createScope(@RequestBody String json, ModelMap m) {

View File

@ -207,20 +207,6 @@ var SystemScopeFormView = Backbone.View.extend({
return false;
}
var valuedata = {};
valuedata.value = value;
var alreadyExists = false;
$.get(this.model.urlRoot + "/checkScopeValue", valuedata)
.success(function() {
console.log("scope value is OK");
})
.error(function(error, response) {
$('#value input').addClass('error');
//add hint
alreadyExists = true;
});
var valid = this.model.set({
value:value,
description:$('#description textarea').val(),
@ -229,7 +215,7 @@ var SystemScopeFormView = Backbone.View.extend({
allowDynReg:$('#allowDynReg input').is(':checked')
});
if (valid && !alreadyExists) {
if (valid) {
var _self = this;
this.model.save({}, {
@ -240,8 +226,14 @@ var SystemScopeFormView = Backbone.View.extend({
error:function(error, response) {
if (response.status == 409) {
//Conflict, scope already exists
$('#value input').css('border', '1px solid red');
//add hint to choose a different value
$('#value input').addClass('error');
alert("A scope with this value already exists; please enter a different value");
$('#value input').bind('click.error', function() {
$('#value input').removeClass('error');
$('#value input').unbind('click.error');
});
}
}
});