Skip to content

Commit

Permalink
Fixing bug when also_create_classifications_from_other_languages is T…
Browse files Browse the repository at this point in the history
…rue for taxonomy.
  • Loading branch information
felixfontein committed May 21, 2017
1 parent ca2d917 commit 8c59277
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion nikola/plugin_categories.py
Expand Up @@ -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>'.
"""
Expand Down
5 changes: 4 additions & 1 deletion nikola/plugins/task/categories.py
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/task/taxonomies.py
Expand Up @@ -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
Expand Down

0 comments on commit 8c59277

Please sign in to comment.