Implement use of the injected 'resolved_object' variable to simplify navigation links of objects in lists. Remove obsolete varaibles_tags. Consolidate get_action_links by means of get_menus_links which supports a list of menus to resolve. Remove obsolete 'list_object_variable_name'. Remove 'resolve_for_source' method which was consolidated with the normal resolve method by means of an optional 'source' argument.

This commit is contained in:
Roberto Rosario
2015-04-06 01:02:48 -04:00
parent eae3b0eba2
commit e27ba5d3d6
20 changed files with 48 additions and 124 deletions

View File

@@ -62,22 +62,7 @@ class Menu(object):
# Unsourced links display always
self._add_links_to_source(links, None)
def resolve_for_source(self, context, source):
request = Variable('request').resolve(context)
current_path = request.META['PATH_INFO']
current_view = resolve(current_path).view_name
result = []
for link in self.bound_links.get(CombinedSource(obj=(source), view=current_view), []):
result.append(link.resolve(context))
for link in self.bound_links.get(source, []):
result.append(link.resolve(context))
return result
def resolve(self, context):
def resolve(self, context, source=None):
request = Variable('request').resolve(context)
current_path = request.META['PATH_INFO']
@@ -87,14 +72,17 @@ class Menu(object):
result = []
navigation_object_list = context.get('navigation_object_list', ['object'])
if source:
resolved_navigation_object_list = [source]
else:
navigation_object_list = context.get('navigation_object_list', ['object'])
# Multiple objects
for navigation_object in navigation_object_list:
try:
resolved_navigation_object_list.append(Variable(navigation_object).resolve(context))
except VariableDoesNotExist:
pass
# Multiple objects
for navigation_object in navigation_object_list:
try:
resolved_navigation_object_list.append(Variable(navigation_object).resolve(context))
except VariableDoesNotExist:
pass
for resolved_navigation_object in resolved_navigation_object_list:
for source, links in self.bound_links.iteritems():