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 24 insertions and 3 deletions:
0 comments (0 inline, 0 general)
development.ini
Show inline comments
 
@@ -162,25 +162,25 @@ proxypass_auth_enabled = false
 
default_encoding = utf8
 

	
 
## overwrite schema of clone url
 
## available vars:
 
## scheme - http/https
 
## user - current user
 
## pass - password 
 
## netloc - network location
 
## path - usually repo_name
 

	
 
#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
 
## comment out issue_pat, issue_server, issue_prefix to enable
 

	
 
## pattern to get the issues from commit messages
 
## default one used here is #<numbers> with a regex passive group for `#`
 
## {id} will be all groups matched from this pattern
 

	
 
issue_pat = (?:\s*#)(\d+)
 

	
 
## server url to the issue, each {id} will be replaced with match
 
@@ -210,26 +210,31 @@ issue_prefix = #
 
## all running rhodecode instances. Leave empty if you don't use it
 
instance_id = 
 

	
 
## alternative return HTTP header for failed authentication. Default HTTP
 
## response is 401 HTTPUnauthorized. Currently HG clients have troubles with 
 
## handling that. Set this variable to 403 to return HTTPForbidden
 
auth_ret_code =
 

	
 
## locking return code. When repository is locked return this HTTP code. 2XX
 
## 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        ####
 
####################################
 
use_celery = false
 
broker.host = localhost
 
broker.vhost = rabbitmqhost
 
broker.port = 5672
 
broker.user = rabbitmq
 
broker.password = qweqwe
 

	
 
celery.imports = rhodecode.lib.celerylib.tasks
 

	
production.ini
Show inline comments
 
@@ -210,26 +210,31 @@ issue_prefix = #
 
## all running rhodecode instances. Leave empty if you don't use it
 
instance_id = 
 

	
 
## alternative return HTTP header for failed authentication. Default HTTP
 
## response is 401 HTTPUnauthorized. Currently HG clients have troubles with 
 
## handling that. Set this variable to 403 to return HTTPForbidden
 
auth_ret_code =
 

	
 
## locking return code. When repository is locked return this HTTP code. 2XX
 
## 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        ####
 
####################################
 
use_celery = false
 
broker.host = localhost
 
broker.vhost = rabbitmqhost
 
broker.port = 5672
 
broker.user = rabbitmq
 
broker.password = qweqwe
 

	
 
celery.imports = rhodecode.lib.celerylib.tasks
 

	
rhodecode/bin/template.ini.mako
Show inline comments
 
@@ -218,27 +218,30 @@ issue_prefix = #
 
<%text>## all running rhodecode instances. Leave empty if you don't use it</%text>
 
instance_id = 
 

	
 
<%text>## alternative return HTTP header for failed authentication. Default HTTP</%text>
 
<%text>## response is 401 HTTPUnauthorized. Currently HG clients have troubles with</%text>
 
<%text>## handling that. Set this variable to 403 to return HTTPForbidden</%text>
 
auth_ret_code =
 

	
 
<%text>## locking return code. When repository is locked return this HTTP code. 2XX</%text>
 
<%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        ####
 
####################################
 
</%text>
 
use_celery = false
 
broker.host = localhost
 
broker.vhost = rabbitmqhost
 
broker.port = 5672
 
broker.user = rabbitmq
 
broker.password = qweqwe
 

	
rhodecode/config/deployment.ini_tmpl
Show inline comments
 
@@ -210,26 +210,31 @@ issue_prefix = #
 
## all running rhodecode instances. Leave empty if you don't use it
 
instance_id = 
 

	
 
## alternative return HTTP header for failed authentication. Default HTTP
 
## response is 401 HTTPUnauthorized. Currently HG clients have troubles with 
 
## handling that. Set this variable to 403 to return HTTPForbidden
 
auth_ret_code =
 

	
 
## locking return code. When repository is locked return this HTTP code. 2XX
 
## 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        ####
 
####################################
 
use_celery = false
 
broker.host = localhost
 
broker.vhost = rabbitmqhost
 
broker.port = 5672
 
broker.user = rabbitmq
 
broker.password = qweqwe
 

	
 
celery.imports = rhodecode.lib.celerylib.tasks
 

	
rhodecode/controllers/admin/settings.py
Show inline comments
 
@@ -300,24 +300,25 @@ class SettingsController(BaseController)
 
#                Session().add(sett)
 

	
 
                Session().commit()
 

	
 
                h.flash(_('Updated VCS settings'), category='success')
 

	
 
            except Exception:
 
                log.error(traceback.format_exc())
 
                h.flash(_('Error occurred during updating '
 
                          'application settings'), category='error')
 

	
 
        if setting_id == 'hooks':
 
            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')
 

	
 
                # check for edits
 
                update = False
 
                _d = request.POST.dict_of_lists()
rhodecode/lib/base.py
Show inline comments
 
@@ -270,24 +270,25 @@ class BaseController(WSGIController):
 
        rc_config = RhodeCodeSetting.get_app_settings()
 
        ## DB stored
 
        c.visual.show_public_icon = str2bool(rc_config.get('rhodecode_show_public_icon'))
 
        c.visual.show_private_icon = str2bool(rc_config.get('rhodecode_show_private_icon'))
 
        c.visual.stylify_metatags = str2bool(rc_config.get('rhodecode_stylify_metatags'))
 
        c.visual.dashboard_items = safe_int(rc_config.get('rhodecode_dashboard_items', 100))
 
        c.visual.repository_fields = str2bool(rc_config.get('rhodecode_repository_fields'))
 
        c.visual.show_version = str2bool(rc_config.get('rhodecode_show_version'))
 

	
 
        ## 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()
 
        c.unread_notifications = NotificationModel()\
 
                        .get_unread_cnt_for_user(c.rhodecode_user.user_id)
 
        self.sa = meta.Session
 
        self.scm_model = ScmModel(self.sa)
 

	
 
    def __call__(self, environ, start_response):
 
        """Invoke the Controller"""
 
        # WSGIController.__call__ dispatches to the Controller method
 
        # the request is routed to. This routing information is
rhodecode/templates/admin/settings/hooks.html
Show inline comments
 
@@ -27,25 +27,25 @@
 
          % for hook in c.hooks:
 
            <div class="field">
 
                <div class="label label">
 
                    <label for="${hook.ui_key}">${hook.ui_key}</label>
 
                </div>
 
                <div class="input" style="margin-left:280px">
 
                  ${h.text(hook.ui_key,hook.ui_value,size=60,readonly="readonly")}
 
                </div>
 
            </div>
 
          % 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">
 
        <div class="fields">
 

	
 
          % for hook in c.custom_hooks:
 
          <div class="field"  id="${'id%s' % hook.ui_id }">
 
            <div class="label label">
 
                <label for="${hook.ui_key}">${hook.ui_key}</label>
 
            </div>
 
            <div class="input" style="margin-left:280px">
 
                ${h.hidden('hook_ui_key',hook.ui_key)}
 
@@ -66,24 +66,25 @@
 
              </div>
 
            </div>
 
            <div class="input" style="margin-left:280px">
 
                ${h.text('new_hook_ui_value',size=60)}
 
            </div>
 
          </div>
 
          <div class="buttons" style="margin-left:280px">
 
             ${h.submit('save',_('Save'),class_="ui-btn large")}
 
          </div>
 
        </div>
 
    </div>
 
    ${h.end_form()}
 
    % endif
 
</div>
 
<script type="text/javascript">
 
function ajaxActionHook(hook_id,field_id) {
 
    var sUrl = "${h.url('admin_setting', setting_id='hooks')}";
 
    var callback = {
 
        success: function (o) {
 
            var elem = YUD.get(""+field_id);
 
            elem.parentNode.removeChild(elem);
 
        },
 
        failure: function (o) {
 
            alert("${_('Failed to remove hook')}");
 
        },
0 comments (0 inline, 0 general)