##// END OF EJS Templates
better detection of deleting groups with subgroups inside....
marcink -
r3458:0ad025ee beta
parent child Browse files
Show More
@@ -56,6 +56,18 b' def make_map(config):'
56 56 repos_group_name = match_dict.get('group_name')
57 57 return is_valid_repos_group(repos_group_name, config['base_path'])
58 58
59 def check_group_skip_path(environ, match_dict):
60 """
61 check for valid repository group for proper 404 handling, but skips
62 verification of existing path
63
64 :param environ:
65 :param match_dict:
66 """
67 repos_group_name = match_dict.get('group_name')
68 return is_valid_repos_group(repos_group_name, config['base_path'],
69 skip_path_check=True)
70
59 71 def check_int(environ, match_dict):
60 72 return match_dict.get('id').isdigit()
61 73
@@ -171,9 +183,10 b' def make_map(config):'
171 183 function=check_group))
172 184 m.connect("delete_repos_group", "/repos_groups/{group_name:.*?}",
173 185 action="delete", conditions=dict(method=["DELETE"],
174 function=check_group))
186 function=check_group_skip_path))
175 187 m.connect("edit_repos_group", "/repos_groups/{group_name:.*?}/edit",
176 action="edit", conditions=dict(method=["GET"],))
188 action="edit", conditions=dict(method=["GET"],
189 function=check_group))
177 190 m.connect("formatted_edit_repos_group",
178 191 "/repos_groups/{group_name:.*?}.{format}/edit",
179 192 action="edit", conditions=dict(method=["GET"],
@@ -251,31 +251,25 b' class ReposGroupsController(BaseControll'
251 251 repos = gr.repositories.all()
252 252 if repos:
253 253 h.flash(_('This group contains %s repositores and cannot be '
254 'deleted') % len(repos),
255 category='error')
254 'deleted') % len(repos), category='warning')
255 return redirect(url('repos_groups'))
256
257 children = gr.children.all()
258 if children:
259 h.flash(_('This group contains %s subgroups and cannot be deleted'
260 % (len(children))), category='warning')
256 261 return redirect(url('repos_groups'))
257 262
258 263 try:
259 264 ReposGroupModel().delete(group_name)
260 265 Session().commit()
261 h.flash(_('removed repos group %s') % gr.group_name,
266 h.flash(_('removed repos group %s') % group_name,
262 267 category='success')
263 268 #TODO: in future action_logger(, '', '', '', self.sa)
264 except IntegrityError, e:
265 if str(e.message).find('groups_group_parent_id_fkey') != -1:
266 log.error(traceback.format_exc())
267 h.flash(_('Cannot delete this group it still contains '
268 'subgroups'),
269 category='warning')
270 else:
271 log.error(traceback.format_exc())
272 h.flash(_('error occurred during deletion of repos '
273 'group %s') % gr.group_name, category='error')
274
275 269 except Exception:
276 270 log.error(traceback.format_exc())
277 271 h.flash(_('error occurred during deletion of repos '
278 'group %s') % gr.group_name, category='error')
272 'group %s') % group_name, category='error')
279 273
280 274 return redirect(url('repos_groups'))
281 275
@@ -240,7 +240,7 b' def is_valid_repo(repo_name, base_path, '
240 240 return False
241 241
242 242
243 def is_valid_repos_group(repos_group_name, base_path):
243 def is_valid_repos_group(repos_group_name, base_path, skip_path_check=False):
244 244 """
245 245 Returns True if given path is a repos group False otherwise
246 246
@@ -263,7 +263,7 b' def is_valid_repos_group(repos_group_nam'
263 263 pass
264 264
265 265 # check if it's a valid path
266 if os.path.isdir(full_path):
266 if skip_path_check or os.path.isdir(full_path):
267 267 return True
268 268
269 269 return False
@@ -495,7 +495,6 b' def repo2db_mapper(initial_repo_list, re'
495 495 #don't hold further removals on error
496 496 log.error(traceback.format_exc())
497 497 sa.rollback()
498
499 498 return added, removed
500 499
501 500
General Comments 0
You need to be logged in to leave comments. Login now