Skip to content
Snippets Groups Projects
Commit 09b04e84 authored by Thomas Uher's avatar Thomas Uher
Browse files

update all_vernacular_names

parent 334dc568
No related branches found
No related tags found
No related merge requests found
...@@ -100,29 +100,35 @@ class LazyTaxon(LazyTaxonBase): ...@@ -100,29 +100,35 @@ class LazyTaxon(LazyTaxonBase):
return None return None
def all_vernacular_names(self, only_preferred=True, cache=None): def all_vernacular_names(self, only_preferred=True, cache=None, language=None):
matches = [] matches = []
found_locales = []
locales = MetaVernacularNames.objects.filter(taxon_latname=self.taxon_latname,
taxon_author=self.taxon_author)
if only_preferred: if not language:
locales = locales.filter(preferred=True) found_locales = []
locales = MetaVernacularNames.objects.filter(taxon_latname=self.taxon_latname,
taxon_author=self.taxon_author)
if only_preferred:
locales = locales.filter(preferred=True)
for locale in locales: for locale in locales:
matches.append(locale) matches.append(locale)
found_locales.append(locale.language) found_locales.append(locale.language)
locales = self.models.TaxonLocaleModel.objects.filter(taxon__taxon_latname=self.taxon_latname, locales = self.models.TaxonLocaleModel.objects.filter(taxon__taxon_latname=self.taxon_latname,
taxon__taxon_author=self.taxon_author).exclude(language__in=found_locales) taxon__taxon_author=self.taxon_author).exclude(language__in=found_locales)
#if only_preferred: #if only_preferred:
# locales = locales.filter(preferred=True) # locales = locales.filter(preferred=True)
for locale in locales: for locale in locales:
matches.append(locale) matches.append(locale)
else:
matches = self.models.TaxonLocaleModel.objects.filter(taxon__taxon_latname=self.taxon_latname,
taxon__taxon_author=self.taxon_author, language=language)
return matches return matches
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment