Skip to content
Permalink
Browse files

Simplifying fake hierarchy creation.

  • Loading branch information
felixfontein committed Jan 6, 2017
1 parent a491cea commit 8a69513ef22fc4dbb177b91e3d1a16dead3a4589
Showing with 16 additions and 15 deletions.
  1. +16 −15 v7/sidebar/sidebar.py
@@ -101,22 +101,23 @@ def invert_order(node):
flat_hierarchy = utils.flatten_tree_structure(root_list)
else:
flat_hierarchy = self.site.flat_hierarchy_per_classification[taxonomy_name][lang]
# Build flattened hierarchy list
hierarchy = [(taxonomy.get_classification_friendly_name(node.classification_name, lang, only_last_component=False),
node.classification_name, node.classification_path,
self.site.link(taxonomy_name, node.classification_name, lang),
node.indent_levels, node.indent_change_before,
node.indent_change_after,
len(node.children),
len([post for post in posts_per_tag[node.classification_name] if acceptor(post)]))
for node in flat_hierarchy]
else:
# Fake hierarchy
hierarchy = [(classification_name, classification, taxonomy.extract_hierarchy(classification),
self.site.link(taxonomy_name, classification, lang),
(i, len(result)), 1 if i == 0 else 0, -1 if i == len(result) - 1 else 0, 0,
count)
for i, ((_, count, link), (classification_name, classification)) in enumerate(zip(result, classifications))]
root_list = []
for classification_name, classification in classifications:
node = utils.TreeNode('')
node.classification_name = classification_name
node.classification_path = taxonomy.extract_hierarchy(classification)
root_list.append(node)
flat_hierarchy = utils.flatten_tree_structure(root_list)
# Build flattened hierarchy list
hierarchy = [(taxonomy.get_classification_friendly_name(node.classification_name, lang, only_last_component=False),
node.classification_name, node.classification_path,
self.site.link(taxonomy_name, node.classification_name, lang),
node.indent_levels, node.indent_change_before,
node.indent_change_after,
len(node.children),
len([post for post in posts_per_tag[node.classification_name] if acceptor(post)]))
for node in flat_hierarchy]
return result, hierarchy
else:
return None, None

0 comments on commit 8a69513

Please sign in to comment.
You can’t perform that action at this time.