##// END OF EJS Templates
usergroup: more descriptive error message when deleting user group
Joseph Rivera -
r4769:2181d005 default
parent child Browse files
Show More
@@ -152,7 +152,7 b' class UserGroupModel(BaseModel):'
152
152
153 def delete(self, user_group, force=False):
153 def delete(self, user_group, force=False):
154 """
154 """
155 Deletes repository group, unless force flag is used
155 Deletes user group, unless force flag is used
156 raises exception if there are members in that group, else deletes
156 raises exception if there are members in that group, else deletes
157 group and users
157 group and users
158
158
@@ -164,10 +164,11 b' class UserGroupModel(BaseModel):'
164 # check if this group is not assigned to repo
164 # check if this group is not assigned to repo
165 assigned_groups = UserGroupRepoToPerm.query()\
165 assigned_groups = UserGroupRepoToPerm.query()\
166 .filter(UserGroupRepoToPerm.users_group == user_group).all()
166 .filter(UserGroupRepoToPerm.users_group == user_group).all()
167 assigned_groups = [x.repository.repo_name for x in assigned_groups]
167
168
168 if assigned_groups and not force:
169 if assigned_groups and not force:
169 raise UserGroupsAssignedException(
170 raise UserGroupsAssignedException(
170 'RepoGroup assigned to %s' % assigned_groups)
171 'User Group assigned to %s' % ", ".join(assigned_groups))
171 self.sa.delete(user_group)
172 self.sa.delete(user_group)
172 except Exception:
173 except Exception:
173 log.error(traceback.format_exc())
174 log.error(traceback.format_exc())
@@ -1568,7 +1568,7 b' class BaseTestApi(object):'
1568 gr_id = ugroup.users_group_id
1568 gr_id = ugroup.users_group_id
1569
1569
1570 ugr_to_perm = RepoModel().grant_user_group_permission(self.REPO, gr_name, 'repository.write')
1570 ugr_to_perm = RepoModel().grant_user_group_permission(self.REPO, gr_name, 'repository.write')
1571 msg = 'RepoGroup assigned to [%s]' % (ugr_to_perm)
1571 msg = 'User Group assigned to %s' % ugr_to_perm.repository.repo_name
1572
1572
1573 id_, params = _build_data(self.apikey, 'delete_user_group',
1573 id_, params = _build_data(self.apikey, 'delete_user_group',
1574 usergroupid=gr_name,
1574 usergroupid=gr_name,
General Comments 0
You need to be logged in to leave comments. Login now