Skip to content
Permalink
Browse files

Fixing bug when also_create_classifications_from_other_languages is T…

…rue for taxonomy.
  • Loading branch information
felixfontein committed May 21, 2017
1 parent ca2d917 commit 8c5927789ee4e45ab4b671aeda25ff107273260c
Showing with 7 additions and 3 deletions.
  1. +2 −1 nikola/plugin_categories.py
  2. +4 −1 nikola/plugins/task/categories.py
  3. +1 −1 nikola/plugins/task/taxonomies.py
@@ -783,7 +783,8 @@ def provide_context_and_uptodate(self, classification, lang, node=None):
the second will be put into the uptodate list of all generated tasks.
For hierarchical taxonomies, node is the `utils.TreeNode` element corresponding
to the classification.
to the classification. Note that `node` can still be `None` if
`also_create_classifications_from_other_languages` is `True`.
Context must contain `title`, which should be something like 'Posts about <classification>'.
"""
@@ -169,7 +169,10 @@ def provide_context_and_uptodate(self, cat, lang, node=None):
"category_pages_titles": self.site.config['CATEGORY_PAGES_TITLES'],
}
posts = self.site.posts_per_classification[self.classification_name][lang]
children = [child for child in node.children if len([post for post in posts.get(child.classification_name, []) if self.site.config['SHOW_UNTRANSLATED_POSTS'] or post.is_translation_available(lang)]) > 0]
if node is None:
children = []
else:
children = [child for child in node.children if len([post for post in posts.get(child.classification_name, []) if self.site.config['SHOW_UNTRANSLATED_POSTS'] or post.is_translation_available(lang)]) > 0]
subcats = [(child.name, self.site.link(self.classification_name, child.classification_name, lang)) for child in children]
friendly_name = self.get_classification_friendly_name(cat, lang)
context = {
@@ -311,7 +311,7 @@ def _generate_classification_page(self, taxonomy, classification, filtered_posts
# Get data
node = None
if taxonomy.has_hierarchy:
node = self.site.hierarchy_lookup_per_classification[taxonomy.classification_name][lang][classification]
node = self.site.hierarchy_lookup_per_classification[taxonomy.classification_name][lang].get(classification)
context, kw = taxonomy.provide_context_and_uptodate(classification, lang, node)
kw = copy(kw)
kw["messages"] = self.site.MESSAGES

0 comments on commit 8c59277

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