# HG changeset patch # User Marcin Lulek # Date 2016-09-09 15:20:22 # Node ID 71ba091b355d92368ebcc033518cb215a8e876b1 # Parent 233ee50e8fe3e04289af9f7e78fe9fa4426b4c0a helpers: added route_path_or_none helper for routes that might be added by plugins diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- 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 --- 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')}