Browse Source

Ref menus.py para renderizar urls sem arg root_pk

pull/701/head
LeandroRoberto 8 years ago
parent
commit
4ec74a8f78
  1. 13
      sapl/base/templatetags/menus.py

13
sapl/base/templatetags/menus.py

@ -1,6 +1,7 @@
import yaml
from django import template from django import template
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
import yaml
register = template.Library() register = template.Library()
@ -28,7 +29,6 @@ def subnav(context, path=None):
if obj: if obj:
root_pk = obj.pk root_pk = obj.pk
if root_pk:
request = context['request'] request = context['request']
""" """
@ -88,8 +88,13 @@ def resolve_urls_inplace(menu, pk, rm, context):
menu['url'] = '' menu['url'] = ''
menu['active'] = '' menu['active'] = ''
else: else:
menu['url'] = reverse( try:
'%s:%s' % (rm.app_name, menu['url']), kwargs={'pk': pk}) menu['url'] = reverse('%s:%s' % (
rm.app_name, menu['url']),
kwargs={'pk': pk})
except:
menu['url'] = reverse('%s:%s' % (rm.app_name, menu['url']))
menu['active'] = 'active'\ menu['active'] = 'active'\
if context['request'].path == menu['url'] else '' if context['request'].path == menu['url'] else ''

Loading…
Cancel
Save