Skip to content
Permalink
Browse files
Avoid creating broken links.
  • Loading branch information
felixfontein committed Jun 11, 2017
1 parent e17cb8c commit 15e9a9a0c3ddab6b3d442d58d8d80d15420c24fd
@@ -142,7 +142,7 @@ def provide_context_and_uptodate(self, classification, lang, node=None):

def get_other_language_variants(self, classification, lang, classifications_per_language):
"""Return a list of variants of the same author in other languages."""
return self.translation_manager.get_translations_as_list(classification, lang)
return self.translation_manager.get_translations_as_list(classification, lang, classifications_per_language)

def postprocess_posts_per_classification(self, posts_per_classification_per_language, flat_hierarchy_per_lang=None, hierarchy_lookup_per_lang=None):
"""Rearrange, modify or otherwise use the list of posts per classification and per language."""
@@ -193,7 +193,7 @@ def provide_context_and_uptodate(self, classification, lang, node=None):

def get_other_language_variants(self, classification, lang, classifications_per_language):
"""Return a list of variants of the same category in other languages."""
return self.translation_manager.get_translations_as_list(classification, lang)
return self.translation_manager.get_translations_as_list(classification, lang, classifications_per_language)

def postprocess_posts_per_classification(self, posts_per_classification_per_language, flat_hierarchy_per_lang=None, hierarchy_lookup_per_lang=None):
"""Rearrange, modify or otherwise use the list of posts per classification and per language."""
@@ -157,4 +157,4 @@ def should_generate_classification_page(self, classification, post_list, lang):

def get_other_language_variants(self, classification, lang, classifications_per_language):
"""Return a list of variants of the same section in other languages."""
return self.translation_manager.get_translations_as_list(classification, lang)
return self.translation_manager.get_translations_as_list(classification, lang, classifications_per_language)
@@ -161,7 +161,7 @@ def provide_context_and_uptodate(self, classification, lang, node=None):

def get_other_language_variants(self, classification, lang, classifications_per_language):
"""Return a list of variants of the same tag in other languages."""
return self.translation_manager.get_translations_as_list(classification, lang)
return self.translation_manager.get_translations_as_list(classification, lang, classifications_per_language)

def postprocess_posts_per_classification(self, posts_per_classification_per_language, flat_hierarchy_per_lang=None, hierarchy_lookup_per_lang=None):
"""Rearrange, modify or otherwise use the list of posts per classification and per language."""
@@ -2002,16 +2002,21 @@ def get_translations(self, classification, lang):
else:
return {other_lang: list(classifications) for other_lang, classifications in cldata.items()}

def get_translations_as_list(self, classification, lang):
"""Get a list of pairs ``(other_lang, other_classification)`` which are translations of ``classification``."""
def get_translations_as_list(self, classification, lang, classifications_per_language):
"""Get a list of pairs ``(other_lang, other_classification)`` which are translations of ``classification``.
Avoid classifications not in ``classifications_per_language``.
"""
clmap = self._data[lang]
cldata = clmap.get(classification)
if cldata is None:
return []
else:
result = []
for other_lang, classifications in cldata.items():
result.extend([(other_lang, other_classification) for other_classification in classifications])
for other_classification in classifications:
if other_classification in classifications_per_language[other_lang]:
result.append((other_lang, other_classification))
return result

def has_translations(self, classification, lang):

0 comments on commit 15e9a9a

Please sign in to comment.