Skip to content

Commit

Permalink
Update related items as per new requirements.
Browse files Browse the repository at this point in the history
  • Loading branch information
oakdbca committed Aug 13, 2024
1 parent 2a7cd73 commit dac3390
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions boranga/components/occurrence/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3744,13 +3744,15 @@ def get_related_items(self, filter_type, **kwargs):
# Add parent species related items to the list (limited to one degree of separation)
if a_field.name == "species" and self.species:
return_list.extend(
self.species.get_related_items("all_except_parent_species")
self.species.get_related_items("all_except_occurrence_reports")
)

# Add renamed from / renamed to community related items to the list
if a_field.name == "community" and self.community:
return_list.extend(
self.community.get_related_items("all_except_renamed_community")
self.community.get_related_items(
"all_except_occurrence_reports"
)
)

# Remove the occurrence itself from the list if it ended up there
Expand Down
13 changes: 13 additions & 0 deletions boranga/components/species_and_communities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,12 @@ def get_related_items(self, filter_type, **kwargs):
"occurrences",
"occurrence_report",
]
elif filter_type == "all_except_occurrence_reports":
related_field_names = [
"parent_species",
"conservation_status",
"occurrences",
]
else:
related_field_names = [
filter_type,
Expand Down Expand Up @@ -1419,6 +1425,13 @@ def get_related_items(self, filter_type, **kwargs):
"occurrences",
"occurrence_report",
]
elif filter_type == "all_except_occurrence_reports":
related_field_names = [
"renamed_from",
"renamed_to",
"conservation_status",
"occurrences",
]
else:
related_field_names = [
filter_type,
Expand Down

0 comments on commit dac3390

Please sign in to comment.