Show More
@@ -35,6 +35,7 b' from paste.httpexceptions import HTTPUna' | |||||
35 | from paste.httpheaders import WWW_AUTHENTICATE, AUTHORIZATION |
|
35 | from paste.httpheaders import WWW_AUTHENTICATE, AUTHORIZATION | |
36 |
|
36 | |||
37 | import rhodecode |
|
37 | import rhodecode | |
|
38 | from rhodecode.apps._base import TemplateArgs | |||
38 | from rhodecode.authentication.base import VCS_TYPE |
|
39 | from rhodecode.authentication.base import VCS_TYPE | |
39 | from rhodecode.lib import auth, utils2 |
|
40 | from rhodecode.lib import auth, utils2 | |
40 | from rhodecode.lib import helpers as h |
|
41 | from rhodecode.lib import helpers as h | |
@@ -312,6 +313,10 b' def attach_context_attributes(context, r' | |||||
312 | rc_config.get('rhodecode_dashboard_items', 100)) |
|
313 | rc_config.get('rhodecode_dashboard_items', 100)) | |
313 | context.visual.admin_grid_items = safe_int( |
|
314 | context.visual.admin_grid_items = safe_int( | |
314 | rc_config.get('rhodecode_admin_grid_items', 100)) |
|
315 | rc_config.get('rhodecode_admin_grid_items', 100)) | |
|
316 | context.visual.show_revision_number = str2bool( | |||
|
317 | rc_config.get('rhodecode_show_revision_number', True)) | |||
|
318 | context.visual.show_sha_length = safe_int( | |||
|
319 | rc_config.get('rhodecode_show_sha_length', 100)) | |||
315 | context.visual.repository_fields = str2bool( |
|
320 | context.visual.repository_fields = str2bool( | |
316 | rc_config.get('rhodecode_repository_fields')) |
|
321 | rc_config.get('rhodecode_repository_fields')) | |
317 | context.visual.show_version = str2bool( |
|
322 | context.visual.show_version = str2bool( | |
@@ -551,7 +556,11 b' def bootstrap_request(**kwargs):' | |||||
551 | from rhodecode.lib.partial_renderer import get_partial_renderer |
|
556 | from rhodecode.lib.partial_renderer import get_partial_renderer | |
552 | return get_partial_renderer(request=self, tmpl_name=tmpl_name) |
|
557 | return get_partial_renderer(request=self, tmpl_name=tmpl_name) | |
553 |
|
558 | |||
554 |
_call_context = |
|
559 | _call_context = TemplateArgs() | |
|
560 | _call_context.visual = TemplateArgs() | |||
|
561 | _call_context.visual.show_sha_length = 12 | |||
|
562 | _call_context.visual.show_revision_number = True | |||
|
563 | ||||
555 | @property |
|
564 | @property | |
556 | def call_context(self): |
|
565 | def call_context(self): | |
557 | return self._call_context |
|
566 | return self._call_context |
@@ -683,23 +683,25 b' def age_component(datetime_iso, value=No' | |||||
683 | datetime_iso, title, tzinfo)) |
|
683 | datetime_iso, title, tzinfo)) | |
684 |
|
684 | |||
685 |
|
685 | |||
686 | def _shorten_commit_id(commit_id): |
|
686 | def _shorten_commit_id(commit_id, commit_len=None): | |
687 | from rhodecode import CONFIG |
|
687 | if commit_len is None: | |
688 | def_len = safe_int(CONFIG.get('rhodecode_show_sha_length', 12)) |
|
688 | request = get_current_request() | |
689 | return commit_id[:def_len] |
|
689 | commit_len = request.call_context.visual.show_sha_length | |
|
690 | return commit_id[:commit_len] | |||
690 |
|
691 | |||
691 |
|
692 | |||
692 | def show_id(commit): |
|
693 | def show_id(commit, show_idx=None, commit_len=None): | |
693 | """ |
|
694 | """ | |
694 | Configurable function that shows ID |
|
695 | Configurable function that shows ID | |
695 | by default it's r123:fffeeefffeee |
|
696 | by default it's r123:fffeeefffeee | |
696 |
|
697 | |||
697 | :param commit: commit instance |
|
698 | :param commit: commit instance | |
698 | """ |
|
699 | """ | |
699 | from rhodecode import CONFIG |
|
700 | if show_idx is None: | |
700 | show_idx = str2bool(CONFIG.get('rhodecode_show_revision_number', True)) |
|
701 | request = get_current_request() | |
|
702 | show_idx = request.call_context.visual.show_revision_number | |||
701 |
|
703 | |||
702 | raw_id = _shorten_commit_id(commit.raw_id) |
|
704 | raw_id = _shorten_commit_id(commit.raw_id, commit_len=commit_len) | |
703 | if show_idx: |
|
705 | if show_idx: | |
704 | return 'r%s:%s' % (commit.idx, raw_id) |
|
706 | return 'r%s:%s' % (commit.idx, raw_id) | |
705 | else: |
|
707 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now