diff --git a/rhodecode/controllers/admin/settings.py b/rhodecode/controllers/admin/settings.py --- a/rhodecode/controllers/admin/settings.py +++ b/rhodecode/controllers/admin/settings.py @@ -309,30 +309,31 @@ class SettingsController(BaseController) 'application settings'), category='error') if setting_id == 'hooks': - ui_key = request.POST.get('new_hook_ui_key') - ui_value = request.POST.get('new_hook_ui_value') - try: + if c.visual.allow_custom_hooks_settings: + ui_key = request.POST.get('new_hook_ui_key') + ui_value = request.POST.get('new_hook_ui_value') + try: - if ui_value and ui_key: - RhodeCodeUi.create_or_update_hook(ui_key, ui_value) - h.flash(_('Added new hook'), - category='success') + if ui_value and ui_key: + RhodeCodeUi.create_or_update_hook(ui_key, ui_value) + h.flash(_('Added new hook'), + category='success') - # check for edits - update = False - _d = request.POST.dict_of_lists() - for k, v in zip(_d.get('hook_ui_key', []), - _d.get('hook_ui_value_new', [])): - RhodeCodeUi.create_or_update_hook(k, v) - update = True + # check for edits + update = False + _d = request.POST.dict_of_lists() + for k, v in zip(_d.get('hook_ui_key', []), + _d.get('hook_ui_value_new', [])): + RhodeCodeUi.create_or_update_hook(k, v) + update = True - if update: - h.flash(_('Updated hooks'), category='success') - Session().commit() - except Exception: - log.error(traceback.format_exc()) - h.flash(_('Error occurred during hook creation'), - category='error') + if update: + h.flash(_('Updated hooks'), category='success') + Session().commit() + except Exception: + log.error(traceback.format_exc()) + h.flash(_('Error occurred during hook creation'), + category='error') return redirect(url('admin_edit_setting', setting_id='hooks'))