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):
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 = []
found_locales = []
locales = MetaVernacularNames.objects.filter(taxon_latname=self.taxon_latname,
taxon_author=self.taxon_author)
if only_preferred:
locales = locales.filter(preferred=True)
if not language:
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:
matches.append(locale)
found_locales.append(locale.language)
for locale in locales:
matches.append(locale)
found_locales.append(locale.language)
locales = self.models.TaxonLocaleModel.objects.filter(taxon__taxon_latname=self.taxon_latname,
taxon__taxon_author=self.taxon_author).exclude(language__in=found_locales)
locales = self.models.TaxonLocaleModel.objects.filter(taxon__taxon_latname=self.taxon_latname,
taxon__taxon_author=self.taxon_author).exclude(language__in=found_locales)
#if only_preferred:
# locales = locales.filter(preferred=True)
#if only_preferred:
# locales = locales.filter(preferred=True)
for locale in locales:
matches.append(locale)
for locale in locales:
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
......
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