Show More
@@ -56,6 +56,18 b' def make_map(config):' | |||||
56 | repos_group_name = match_dict.get('group_name') |
|
56 | repos_group_name = match_dict.get('group_name') | |
57 | return is_valid_repos_group(repos_group_name, config['base_path']) |
|
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 | def check_int(environ, match_dict): |
|
71 | def check_int(environ, match_dict): | |
60 | return match_dict.get('id').isdigit() |
|
72 | return match_dict.get('id').isdigit() | |
61 |
|
73 | |||
@@ -171,9 +183,10 b' def make_map(config):' | |||||
171 | function=check_group)) |
|
183 | function=check_group)) | |
172 | m.connect("delete_repos_group", "/repos_groups/{group_name:.*?}", |
|
184 | m.connect("delete_repos_group", "/repos_groups/{group_name:.*?}", | |
173 | action="delete", conditions=dict(method=["DELETE"], |
|
185 | action="delete", conditions=dict(method=["DELETE"], | |
174 | function=check_group)) |
|
186 | function=check_group_skip_path)) | |
175 | m.connect("edit_repos_group", "/repos_groups/{group_name:.*?}/edit", |
|
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 | m.connect("formatted_edit_repos_group", |
|
190 | m.connect("formatted_edit_repos_group", | |
178 | "/repos_groups/{group_name:.*?}.{format}/edit", |
|
191 | "/repos_groups/{group_name:.*?}.{format}/edit", | |
179 | action="edit", conditions=dict(method=["GET"], |
|
192 | action="edit", conditions=dict(method=["GET"], |
@@ -251,31 +251,25 b' class ReposGroupsController(BaseControll' | |||||
251 | repos = gr.repositories.all() |
|
251 | repos = gr.repositories.all() | |
252 | if repos: |
|
252 | if repos: | |
253 | h.flash(_('This group contains %s repositores and cannot be ' |
|
253 | h.flash(_('This group contains %s repositores and cannot be ' | |
254 | 'deleted') % len(repos), |
|
254 | 'deleted') % len(repos), category='warning') | |
255 | category='error') |
|
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 | return redirect(url('repos_groups')) |
|
261 | return redirect(url('repos_groups')) | |
257 |
|
262 | |||
258 | try: |
|
263 | try: | |
259 | ReposGroupModel().delete(group_name) |
|
264 | ReposGroupModel().delete(group_name) | |
260 | Session().commit() |
|
265 | Session().commit() | |
261 |
h.flash(_('removed repos group %s') % |
|
266 | h.flash(_('removed repos group %s') % group_name, | |
262 | category='success') |
|
267 | category='success') | |
263 | #TODO: in future action_logger(, '', '', '', self.sa) |
|
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 | except Exception: |
|
269 | except Exception: | |
276 | log.error(traceback.format_exc()) |
|
270 | log.error(traceback.format_exc()) | |
277 | h.flash(_('error occurred during deletion of repos ' |
|
271 | h.flash(_('error occurred during deletion of repos ' | |
278 |
'group %s') % |
|
272 | 'group %s') % group_name, category='error') | |
279 |
|
273 | |||
280 | return redirect(url('repos_groups')) |
|
274 | return redirect(url('repos_groups')) | |
281 |
|
275 |
@@ -240,7 +240,7 b' def is_valid_repo(repo_name, base_path, ' | |||||
240 | return False |
|
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 | Returns True if given path is a repos group False otherwise |
|
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 | pass |
|
263 | pass | |
264 |
|
264 | |||
265 | # check if it's a valid path |
|
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 | return True |
|
267 | return True | |
268 |
|
268 | |||
269 | return False |
|
269 | return False | |
@@ -495,7 +495,6 b' def repo2db_mapper(initial_repo_list, re' | |||||
495 | #don't hold further removals on error |
|
495 | #don't hold further removals on error | |
496 | log.error(traceback.format_exc()) |
|
496 | log.error(traceback.format_exc()) | |
497 | sa.rollback() |
|
497 | sa.rollback() | |
498 |
|
||||
499 | return added, removed |
|
498 | return added, removed | |
500 |
|
499 | |||
501 |
|
500 |
General Comments 0
You need to be logged in to leave comments.
Login now