Skip to content

Commit

Permalink
link_active split for pylons and flask requests
Browse files Browse the repository at this point in the history
  • Loading branch information
tino097 committed Oct 6, 2017
1 parent 76abcec commit 6452479
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions ckan/lib/helpers.py
Expand Up @@ -685,12 +685,25 @@ def are_there_flash_messages():

def _link_active(kwargs):
''' creates classes for the link_to calls '''
highlight_actions = kwargs.get('highlight_actions',
kwargs.get('action', '')).split()
return (c.controller == kwargs.get('controller')
if is_flask_request():
return _link_active_flask(kwargs)
else:
return _link_active_pylons(kwargs)


def _link_active_pylons(kwargs):
highlight_actions = kwargs.get('highlight_actions',
kwargs.get('action', '')).split()
return (c.controller == kwargs.get('controller')
and c.action in highlight_actions)


def _link_active_flask(kwargs):
controller, action = request.url_rule.endpoint.split('.')
return(kwargs.get('controller') == controller and
kwargs.get('action') == action)


def _link_to(text, *args, **kwargs):
'''Common link making code for several helper functions'''
assert len(args) < 2, 'Too many unnamed arguments'
Expand Down

0 comments on commit 6452479

Please sign in to comment.