diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -35,6 +35,7 @@ from paste.httpexceptions import HTTPUna from paste.httpheaders import WWW_AUTHENTICATE, AUTHORIZATION import rhodecode +from rhodecode.apps._base import TemplateArgs from rhodecode.authentication.base import VCS_TYPE from rhodecode.lib import auth, utils2 from rhodecode.lib import helpers as h @@ -312,6 +313,10 @@ def attach_context_attributes(context, r rc_config.get('rhodecode_dashboard_items', 100)) context.visual.admin_grid_items = safe_int( rc_config.get('rhodecode_admin_grid_items', 100)) + context.visual.show_revision_number = str2bool( + rc_config.get('rhodecode_show_revision_number', True)) + context.visual.show_sha_length = safe_int( + rc_config.get('rhodecode_show_sha_length', 100)) context.visual.repository_fields = str2bool( rc_config.get('rhodecode_repository_fields')) context.visual.show_version = str2bool( @@ -551,7 +556,11 @@ def bootstrap_request(**kwargs): from rhodecode.lib.partial_renderer import get_partial_renderer return get_partial_renderer(request=self, tmpl_name=tmpl_name) - _call_context = {} + _call_context = TemplateArgs() + _call_context.visual = TemplateArgs() + _call_context.visual.show_sha_length = 12 + _call_context.visual.show_revision_number = True + @property def call_context(self): return self._call_context diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -683,23 +683,25 @@ def age_component(datetime_iso, value=No datetime_iso, title, tzinfo)) -def _shorten_commit_id(commit_id): - from rhodecode import CONFIG - def_len = safe_int(CONFIG.get('rhodecode_show_sha_length', 12)) - return commit_id[:def_len] +def _shorten_commit_id(commit_id, commit_len=None): + if commit_len is None: + request = get_current_request() + commit_len = request.call_context.visual.show_sha_length + return commit_id[:commit_len] -def show_id(commit): +def show_id(commit, show_idx=None, commit_len=None): """ Configurable function that shows ID by default it's r123:fffeeefffeee :param commit: commit instance """ - from rhodecode import CONFIG - show_idx = str2bool(CONFIG.get('rhodecode_show_revision_number', True)) + if show_idx is None: + request = get_current_request() + show_idx = request.call_context.visual.show_revision_number - raw_id = _shorten_commit_id(commit.raw_id) + raw_id = _shorten_commit_id(commit.raw_id, commit_len=commit_len) if show_idx: return 'r%s:%s' % (commit.idx, raw_id) else: