Initial commit of the new class based and menu based navigation system
This commit is contained in:
@@ -2,7 +2,6 @@ from __future__ import unicode_literals
|
||||
|
||||
object_navigation = {}
|
||||
model_list_columns = {}
|
||||
top_menu_entries = []
|
||||
|
||||
|
||||
def register_links(src, links, menu_name=None, position=None):
|
||||
@@ -28,31 +27,6 @@ def register_links(src, links, menu_name=None, position=None):
|
||||
object_navigation[menu_name][src]['links'].extend(links)
|
||||
|
||||
|
||||
def register_top_menu(name, link, position=None):
|
||||
"""
|
||||
Register a new menu entry for the main menu displayed at the top
|
||||
of the page
|
||||
"""
|
||||
|
||||
entry = {'link': link, 'name': name}
|
||||
if position is not None:
|
||||
entry['position'] = position
|
||||
top_menu_entries.insert(position, entry)
|
||||
else:
|
||||
length = len(top_menu_entries)
|
||||
entry['position'] = length
|
||||
top_menu_entries.append(entry)
|
||||
|
||||
sort_menu_entries()
|
||||
|
||||
return entry
|
||||
|
||||
|
||||
def sort_menu_entries():
|
||||
global top_menu_entries
|
||||
top_menu_entries = sorted(top_menu_entries, key=lambda k: (k['position'] < 0, k['position']))
|
||||
|
||||
|
||||
def register_model_list_columns(model, columns):
|
||||
"""
|
||||
Define which columns will be displayed in the generic list template
|
||||
|
||||
Reference in New Issue
Block a user