# HG changeset patch # User Marcin Lulek # Date 2016-07-07 12:15:03 # Node ID c560756ceb8e7b0ad56932d3051e7deba0eda9b8 # Parent 0f3ae6529c62643dbf24215fff0fdf8f33e27cb4 templateContext: allow for flexible way to communicate additional info for client code from controllers diff --git a/rhodecode/controllers/pullrequests.py b/rhodecode/controllers/pullrequests.py --- a/rhodecode/controllers/pullrequests.py +++ b/rhodecode/controllers/pullrequests.py @@ -640,6 +640,9 @@ class PullrequestsController(BaseRepoCon pull_request_id = safe_int(pull_request_id) c.pull_request = PullRequest.get_or_404(pull_request_id) + if hasattr(c, 'pylons_dispatch_info'): + c.pylons_dispatch_info['extra']['pull_request'] = pull_request_id + # pull_requests repo_name we opened it against # ie. target_repo must match if repo_name != c.pull_request.target_repo.repo_name: diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -425,6 +425,12 @@ class BaseController(WSGIController): _route_name = '.'.join([environ['pylons.routes_dict']['controller'], environ['pylons.routes_dict']['action']]) + c.pylons_dispatch_info = { + 'controller': environ['pylons.routes_dict']['controller'], + 'action': environ['pylons.routes_dict']['action'], + 'extra': {'plugins': {}} + } + self.rc_config = SettingsModel().get_all_settings(cache=True) self.ip_addr = get_ip_addr(environ) diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -69,6 +69,7 @@ from webhelpers2.number import format_by from rhodecode.lib.annotate import annotate_highlight from rhodecode.lib.action_parser import action_parser +from rhodecode.lib.ext_json import json from rhodecode.lib.utils import repo_name_slug, get_custom_lexer from rhodecode.lib.utils2 import str2bool, safe_unicode, safe_str, \ get_commit_safe, datetime_to_time, time_to_datetime, time_to_utcdatetime, \ diff --git a/rhodecode/templates/base/root.html b/rhodecode/templates/base/root.html --- a/rhodecode/templates/base/root.html +++ b/rhodecode/templates/base/root.html @@ -45,7 +45,8 @@ timeago: { refresh_time: ${120 * 1000}, cutoff_limit: ${1000*60*60*24*7} - } + }, + dispatch_info: ${h.json.dumps(getattr(c, 'pylons_dispatch_info', {}))|n} }