diff --git a/apps/navigation/api.py b/apps/navigation/api.py
index 3802cc72e1..15f0a2c8ad 100644
--- a/apps/navigation/api.py
+++ b/apps/navigation/api.py
@@ -75,6 +75,9 @@ class Link(object):
resolved_link = ResolvedLink()
resolved_link.text = self.text
resolved_link.sprite = self.sprite
+ resolved_link.icon = self.icon
+ resolved_link.permissions = self.permissions
+
try:
#args, kwargs = resolve_arguments(context, self.get('args', {}))
args, kwargs = resolve_arguments(context, self.args)
@@ -167,24 +170,7 @@ def bind_links(sources, links, menu_name=None, position=0):
link_binding[menu_name][source]['links'].extend(links)
-def register_multi_item_links(src, links, menu_name=None):
- """
- Register a multiple item action action to be displayed in the
- generic list template
- """
- # TODO: simplify by removing __iter__ support
- multi_object_navigation.setdefault(menu_name, {})
- if hasattr(src, '__iter__'):
- for one_src in src:
- multi_object_navigation[menu_name].setdefault(one_src, {'links': []})
- multi_object_navigation[menu_name][one_src]['links'].extend(links)
- else:
- multi_object_navigation[menu_name].setdefault(src, {'links': []})
- multi_object_navigation[menu_name][src]['links'].extend(links)
-
-
-#def register_top_menu(name, link, children_views=None, children_path_regex=None, children_view_regex=None, position=None):
-def register_top_menu(name, link, children_view_regex=None, position=None):
+def register_top_menu(name, link, position=None):
"""
Register a new menu entry for the main menu displayed at the top
of the page
@@ -216,6 +202,23 @@ def register_sidebar_template(source_list, template_name):
sidebar_templates[source].append(template_name)
+# TODO
+def register_multi_item_links(src, links, menu_name=None):
+ """
+ Register a multiple item action action to be displayed in the
+ generic list template
+ """
+ # TODO: simplify by removing __iter__ support
+ multi_object_navigation.setdefault(menu_name, {})
+ if hasattr(src, '__iter__'):
+ for one_src in src:
+ multi_object_navigation[menu_name].setdefault(one_src, {'links': []})
+ multi_object_navigation[menu_name][one_src]['links'].extend(links)
+ else:
+ multi_object_navigation[menu_name].setdefault(src, {'links': []})
+ multi_object_navigation[menu_name][src]['links'].extend(links)
+
+
def get_context_object_navigation_links(context, menu_name=None, links_dict=object_navigation):
request = Variable('request').resolve(context)
current_path = request.META['PATH_INFO']
diff --git a/apps/navigation/templatetags/navigation_tags.py b/apps/navigation/templatetags/navigation_tags.py
index 49df4df77a..54bfcdbd00 100644
--- a/apps/navigation/templatetags/navigation_tags.py
+++ b/apps/navigation/templatetags/navigation_tags.py
@@ -27,24 +27,6 @@ logger = logging.getLogger(__name__)
class TopMenuNavigationNode(Node):
def render(self, context):
- #request = Variable('request').resolve(context)
- #current_path = request.META['PATH_INFO']
- #current_view = resolve_to_name(current_path)
-
- #all_menu_links = []#[entry.get('link', {}) for entry in top_menu_entries]
- #menu_links = resolve_links(context, all_menu_links, current_view, current_path)
-
- #for index, link in enumerate(top_menu_entries):
- # #if current_view in link.get('children_views', []):
- # # menu_links[index]['active'] = True
- # #for child_path_regex in link.get('children_path_regex', []):
- # # if re.compile(child_path_regex).match(current_path.lstrip('/')):
- # # menu_links[index]['active'] = True
- # #for children_view_regex in link.get('children_view_regex', []):
- # # if re.compile(children_view_regex).match(current_view):
- # # menu_links[index]['active'] = True
- # pass
- #context['menu_links'] = []#menu_links
context['menu_links'] = [menu.get('link').resolve(context) for menu in main_menu.getchildren()]
return ''
@@ -84,10 +66,10 @@ def get_object_navigation_links(parser, token):
@register.inclusion_tag('generic_navigation.html', takes_context=True)
def object_navigation_template(context):
new_context = copy.copy(context)
- #new_context.update({
- # 'horizontal': True,
- # 'object_navigation_links': get_object_navigation_links(context)
- #})
+ new_context.update({
+ 'horizontal': True,
+ 'object_navigation_links': get_context_object_navigation_links(context)
+ })
return new_context
@@ -106,7 +88,7 @@ def get_multi_item_links(parser, token):
def get_multi_item_links_form(context):
new_context = copy.copy(context)
new_context.update({
- 'form': MultiItemForm(actions=[(link['url'], link['text']) for link in get_context_object_navigation_links(context, links_dict=multi_object_navigation)]),
+ 'form': MultiItemForm(actions=[(link.url, link.text) for link in get_context_object_navigation_links(context, links_dict=multi_object_navigation)]),
'title': _(u'Selected item actions:'),
'form_action': reverse('multi_object_action_view'),
'submit_method': 'get',
diff --git a/apps/navigation/widgets.py b/apps/navigation/widgets.py
index d17cd6574e..21ead7e606 100644
--- a/apps/navigation/widgets.py
+++ b/apps/navigation/widgets.py
@@ -12,7 +12,6 @@ from django.template import RequestContext, Variable
from permissions.models import Permission
-#from .templatetags.navigation_tags import resolve_links
from .utils import resolve_to_name
@@ -29,23 +28,11 @@ def button_navigation_widget(request, link):
def render_widget(request, link):
context = RequestContext(request)
-
- request = Variable('request').resolve(context)
- current_path = request.META['PATH_INFO']
- current_view = resolve_to_name(current_path)
-
- query_string = urlparse.urlparse(request.get_full_path()).query or urlparse.urlparse(request.META.get('HTTP_REFERER', u'/')).query
- parsed_query_string = urlparse.parse_qs(query_string)
-
- links = []#resolve_links(context, [link], current_view, current_path, parsed_query_string)
- if links:
- link = links[0]
- return mark_safe(u'' % {
- 'url': reverse(link['view']) if 'view' in link else link['url'],
- 'icon': link.getattr('icon', 'link_button.png'),
- 'static_url': settings.STATIC_URL,
- 'string': capfirst(link['text']),
- 'image_alt': _(u'icon'),
- })
- else:
- return u''
+ resolved_link = link.resolve(context)
+ return mark_safe(u'' % {
+ 'url': resolved_link.url,
+ 'icon': getattr(resolved_link, 'icon', 'link_button.png'),
+ 'static_url': settings.STATIC_URL,
+ 'string': capfirst(resolved_link.text),
+ 'image_alt': _(u'icon'),
+ })
diff --git a/apps/tags/__init__.py b/apps/tags/__init__.py
index e024a7ad3f..ec5df2c9db 100644
--- a/apps/tags/__init__.py
+++ b/apps/tags/__init__.py
@@ -49,7 +49,7 @@ register_model_list_columns(Document, [
bind_links([Tag], [tag_tagged_item_list, tag_edit, tag_delete, tag_acl_list])
register_multi_item_links(['tag_list'], [tag_multiple_delete])
bind_links([Tag, 'tag_list', 'tag_create'], [tag_list, tag_create], menu_name='secondary_menu')
-register_top_menu('tags', link=Link(text=_(u'tags'), view='tag_list', sprite='tag_blue'), children_view_regex=[r'^tag_(list|create|delete|edit|tagged|acl)'])
+register_top_menu('tags', link=Link(text=_(u'tags'), view='tag_list', sprite='tag_blue', children_view_regex=[r'^tag_(list|create|delete|edit|tagged|acl)']))
bind_links([Document], [tag_document_list], menu_name='form_header')
bind_links(['document_tags', 'tag_remove', 'tag_multiple_remove', 'tag_attach'], [tag_attach], menu_name='sidebar')