Refactored the tools menu and added method for apps to register tools themselves
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user