diff rhodecode/controllers/admin/settings.py @ 4045:9b4ba12ef8c3

Add ini option to controll custom advanced hooks settings
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 27 Jun 2013 00:47:15 +0200
parents 5293d4bbb1ea
children 7676606f7622
line wrap: on
line diff
--- a/rhodecode/controllers/admin/settings.py	Thu Jun 27 00:30:06 2013 +0200
+++ b/rhodecode/controllers/admin/settings.py	Thu Jun 27 00:47:15 2013 +0200
@@ -309,30 +309,31 @@
                           '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'))