From a045ce12621faecbd6efbb088e2aaea3cb76b53a Mon Sep 17 00:00:00 2001 From: Marcin Lulek Date: Fri, 9 Sep 2016 17:20:22 +0200 Subject: [PATCH] helpers: added route_path_or_none helper for routes that might be added by plugins --- rhodecode/lib/helpers.py | 7 +++++++ rhodecode/templates/admin/my_account/my_account.html | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py index e7984eb9..e96c3caf 100644 --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -1946,6 +1946,13 @@ def route_path(*args, **kwds): return req.route_path(*args, **kwds) +def route_path_or_none(*args, **kwargs): + try: + return route_path(*args, **kwargs) + except KeyError: + return None + + def static_url(*args, **kwds): """ Wrapper around pyramids `route_path` function. It is used to generate diff --git a/rhodecode/templates/admin/my_account/my_account.html b/rhodecode/templates/admin/my_account/my_account.html index 53e027e0..02a8e0b2 100644 --- a/rhodecode/templates/admin/my_account/my_account.html +++ b/rhodecode/templates/admin/my_account/my_account.html @@ -30,10 +30,10 @@
  • ${_('Password')}
  • ${_('Auth Tokens')}
  • ## TODO: Find a better integration of oauth views into navigation. - %try: -
  • ${_('OAuth Identities')}
  • - %except KeyError: - %endtry + <% my_account_oauth_url = h.route_path_or_none('my_account_oauth') %> + % if my_account_oauth_url: +
  • ${_('OAuth Identities')}
  • + % endif
  • ${_('My Emails')}
  • ${_('My Repositories')}
  • ${_('Watched')}