Skip to content

Commit

Permalink
This Closes #678 Handled Empty Group name in Front end and Back end
Browse files Browse the repository at this point in the history
  • Loading branch information
scottx611x committed Sep 15, 2015
1 parent c48692d commit 238b3de
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
7 changes: 7 additions & 0 deletions refinery/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,13 @@ def get_managed_group(self):
except:
return None

def save(self, *args, **kwargs):
if len(self.name) == 0 or self.name is False:
logger.error("Group name cannot be empty.")
return
else:
super(ExtendedGroup, self).save(*args, **kwargs) # Call the "real" save() method.


# automatic creation of a managed group when an extended group is created:
def create_manager_group(sender, instance, created, **kwargs):
Expand Down
26 changes: 19 additions & 7 deletions refinery/ui/src/js/collaboration/controllers/add-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,31 @@ function AddGroupCtrl($modalInstance, groupService, groupDataService) {
that.groupDataService = groupDataService;
}

function isEmptyOrSpaces(str){

return str === undefined || str === "" || str == " " || str === null || str.match(/^\s*$/) !== null || str.length === 0;
}


AddGroupCtrl.prototype.createGroup = function (name) {
var that = this;

this.groupService.create({
name: name
}).$promise.then(
function (data) {

this.groupService.create({name: name }).$promise.then(function (data) {

that.groupDataService.update();
that.$modalInstance.dismiss();

}
).catch(function (error) {
console.error(error);
bootbox.alert("This name probably already exists - try a different name.");

if(isEmptyOrSpaces(name)){
bootbox.alert("Group Name cannot be left blank - try a different name.");
}
else{
console.error(error);
bootbox.alert("This name probably already exists - try a different name.");
}

});
};

Expand Down

0 comments on commit 238b3de

Please sign in to comment.