Refactored the tools menu and added method for apps to register tools themselves

This commit is contained in:
Roberto Rosario
2011-05-03 21:58:55 -04:00
parent ae35e89549
commit 438e8c89a9
10 changed files with 87 additions and 48 deletions

View File

@@ -1,6 +1,9 @@
from django.core.urlresolvers import reverse
from django.utils.functional import lazy
diagnostics = {}
tools = {}
reverse_lazy = lazy(reverse, str)
def register_diagnostic(namespace, title, link):
@@ -9,3 +12,11 @@ def register_diagnostic(namespace, title, link):
link['url'] = link.get('url', reverse(link['view']))
namespace_dict['links'].append(link)
diagnostics[namespace] = namespace_dict
def register_tool(link, title=None, namespace=None):
namespace_dict = tools.get(namespace, {'title': None, 'links': []})
namespace_dict['title'] = title
link['url'] = link.get('url', reverse_lazy(link['view']))
namespace_dict['links'].append(link)
tools[namespace] = namespace_dict