helpers: added route_path_or_none helper for routes that might be added by plugins
This commit is contained in:
parent
7a7102fedd
commit
a045ce1262
2 changed files with 11 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@
|
|||
<li class="${'active' if c.active=='password' else ''}"><a href="${h.url('my_account_password')}">${_('Password')}</a></li>
|
||||
<li class="${'active' if c.active=='auth_tokens' else ''}"><a href="${h.url('my_account_auth_tokens')}">${_('Auth Tokens')}</a></li>
|
||||
## TODO: Find a better integration of oauth views into navigation.
|
||||
%try:
|
||||
<li class="${'active' if c.active=='oauth' else ''}"><a href="${h.route_path('my_account_oauth')}">${_('OAuth Identities')}</a></li>
|
||||
%except KeyError:
|
||||
%endtry
|
||||
<% my_account_oauth_url = h.route_path_or_none('my_account_oauth') %>
|
||||
% if my_account_oauth_url:
|
||||
<li class="${'active' if c.active=='oauth' else ''}"><a href="${my_account_oauth_url}">${_('OAuth Identities')}</a></li>
|
||||
% endif
|
||||
<li class="${'active' if c.active=='emails' else ''}"><a href="${h.url('my_account_emails')}">${_('My Emails')}</a></li>
|
||||
<li class="${'active' if c.active=='repos' else ''}"><a href="${h.url('my_account_repos')}">${_('My Repositories')}</a></li>
|
||||
<li class="${'active' if c.active=='watched' else ''}"><a href="${h.url('my_account_watched')}">${_('Watched')}</a></li>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue