Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions backend/apps/api/v1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2422,19 +2422,10 @@ def get_spatial_coverage_name(resources: list, locale: str = "pt") -> list:
- If areas = [br_mg_3100104, br_sp_3500105] -> returns [Belo Horizonte, São Paulo]
- If areas = [br_mg, us_ny, us] -> returns [Minas Gerais, United States] (en)
returns [Minas Gerais, Estados Unidos] (pt)
- If areas = [br_mg, world, us] -> returns [World] (en)
returns [Mundo] (pt)
- If areas = [br_mg, world, us] -> returns [International] (en)
returns [Internacional] (pt)
- If resources have no areas -> returns empty list
"""
# Translation mapping for special cases
translations = {
"world": {
"pt": "Mundo",
"en": "World",
"es": "Mundo",
}
}

# Collect all unique areas (both slug and name) across resources
all_areas = {}
for resource in resources:
Expand All @@ -2449,9 +2440,12 @@ def get_spatial_coverage_name(resources: list, locale: str = "pt") -> list:
if not all_areas:
return []

# If 'world' is present, it encompasses everything
# If 'world' is present, it encompasses everything. Use the Area's own
# localized name rather than a hardcoded string: the record is named
# "Internacional"/"International", and a literal here silently overrode it
# so every dataset covering the world displayed "Mundo"/"World" instead.
if "world" in all_areas:
return [translations["world"].get(locale, translations["world"]["pt"])]
return [all_areas["world"]]

# Filter out areas that have a parent in the set
filtered_areas = set()
Expand Down