|
|
@ -19,15 +19,20 @@ def subnav(context, path=None): |
|
|
|
# TODO: 118n !!!!!!!!!!!!!! |
|
|
|
# How to internationalize yaml files???? |
|
|
|
menu = None |
|
|
|
if 'object' in context: |
|
|
|
obj = context['object'] |
|
|
|
app = obj.__class__._meta.app_label |
|
|
|
root_pk = context.get('root_pk', None) |
|
|
|
if not root_pk: |
|
|
|
obj = context.get('object', None) |
|
|
|
if obj: |
|
|
|
root_pk = obj.pk |
|
|
|
if root_pk: |
|
|
|
request = context['request'] |
|
|
|
app = request.resolver_match.app_name |
|
|
|
default_path = '%s/subnav.yaml' % app |
|
|
|
path = os.path.join(TEMPLATES_DIR, path or default_path) |
|
|
|
if os.path.exists(path): |
|
|
|
menu = yaml.load(open(path, 'r')) |
|
|
|
resolve_urls_inplace(menu, obj.pk, app) |
|
|
|
return dict(menu=menu) |
|
|
|
resolve_urls_inplace(menu, root_pk, app) |
|
|
|
return {'menu': menu} |
|
|
|
|
|
|
|
|
|
|
|
def resolve_urls_inplace(menu, pk, app): |
|
|
|