Changeset - 9b4ba12ef8c3
[Not reviewed]
default
0 7 0
Marcin Kuzminski - 12 years ago 2013-06-27 00:47:15
marcin@python-works.com
Add ini option to controll custom advanced hooks settings
7 files changed with 45 insertions and 24 deletions:
0 comments (0 inline, 0 general)
development.ini
Show inline comments
 
@@ -171,7 +171,7 @@ default_encoding = utf8
 

	
 
#clone_uri = {scheme}://{user}{pass}{netloc}{path}
 

	
 
## issue tracker RhodeCode (leave blank to disable, absent for default)
 
## issue tracker for RhodeCode (leave blank to disable, absent for default)
 
#bugtracker = http://bitbucket.org/marcinkuzminski/rhodecode/issues
 

	
 
## issue tracking mapping for commits messages
 
@@ -219,8 +219,13 @@ auth_ret_code =
 
## codes don't break the transactions while 4XX codes do
 
lock_ret_code = 423
 

	
 
## allows to change the repository location in settings page
 
allow_repo_location_change = True
 

	
 
## allows to setup custom hooks in settings page
 
allow_custom_hooks_settings = True
 

	
 

	
 
####################################
 
###        CELERY CONFIG        ####
 
####################################
production.ini
Show inline comments
 
@@ -219,8 +219,13 @@ auth_ret_code =
 
## codes don't break the transactions while 4XX codes do
 
lock_ret_code = 423
 

	
 
## allows to change the repository location in settings page
 
allow_repo_location_change = True
 

	
 
## allows to setup custom hooks in settings page
 
allow_custom_hooks_settings = True
 

	
 

	
 
####################################
 
###        CELERY CONFIG        ####
 
####################################
rhodecode/bin/template.ini.mako
Show inline comments
 
@@ -227,9 +227,12 @@ auth_ret_code =
 
<%text>## codes don't break the transactions while 4XX codes do</%text>
 
lock_ret_code = 423
 

	
 
<%text>## allow chaning the repository store location from web interface</%text>
 
<%text>## allows to change the repository location in settings page</%text>
 
allow_repo_location_change = True
 

	
 
<%text>## allows to setup custom hooks in settings page</%text>
 
allow_custom_hooks_settings = True
 

	
 
<%text>
 
####################################
 
###        CELERY CONFIG        ####
rhodecode/config/deployment.ini_tmpl
Show inline comments
 
@@ -219,8 +219,13 @@ auth_ret_code =
 
## codes don't break the transactions while 4XX codes do
 
lock_ret_code = 423
 

	
 
## allows to change the repository location in settings page
 
allow_repo_location_change = True
 

	
 
## allows to setup custom hooks in settings page
 
allow_custom_hooks_settings = True
 

	
 

	
 
####################################
 
###        CELERY CONFIG        ####
 
####################################
rhodecode/controllers/admin/settings.py
Show inline comments
 
@@ -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'))
 

	
rhodecode/lib/base.py
Show inline comments
 
@@ -279,6 +279,7 @@ class BaseController(WSGIController):
 
        ## INI stored
 
        self.cut_off_limit = int(config.get('cut_off_limit'))
 
        c.visual.allow_repo_location_change = str2bool(config.get('allow_repo_location_change', True))
 
        c.visual.allow_custom_hooks_settings = str2bool(config.get('allow_custom_hooks_settings', True))
 

	
 
        c.repo_name = get_repo_slug(request)  # can be empty
 
        c.backends = BACKENDS.keys()
rhodecode/templates/admin/settings/hooks.html
Show inline comments
 
@@ -36,7 +36,7 @@
 
          % endfor
 
        </div>
 
    </div>
 

	
 
    % if c.visual.allow_custom_hooks_settings:
 
    <h3>${_('Custom hooks')}</h3>
 
    ${h.form(url('admin_setting', setting_id='hooks'),method='put')}
 
    <div class="form">
 
@@ -75,6 +75,7 @@
 
        </div>
 
    </div>
 
    ${h.end_form()}
 
    % endif
 
</div>
 
<script type="text/javascript">
 
function ajaxActionHook(hook_id,field_id) {
0 comments (0 inline, 0 general)