Skip to content

Commit

Permalink
Merge branch 'master' into collection_expansions
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Jan 7, 2022
2 parents 45ad4dc + c503aaa commit 15c25cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
API_VERSION = '2.0.108'
API_VERSION = '2.0.109'
API_BUILD = 'dev'
VERSION = API_VERSION + '-' + API_BUILD
__version__ = VERSION
10 changes: 6 additions & 4 deletions core/concepts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,8 @@ def cascade_as_hierarchy( # pylint: disable=too-many-arguments
source_mappings, source_to_concepts, mappings_criteria,
cascade_mappings, cascade_hierarchy, include_mappings, False
)
last_level_concepts = list(self.cascaded_entries['concepts'])
last_level_concepts = list(
set(list(self.cascaded_entries['hierarchy_concepts']) + list(self.cascaded_entries['concepts'])))
self.cascaded_entries['concepts'] = last_level_concepts
self.current_level = 0
levels = {self.current_level: last_level_concepts}
Expand All @@ -956,7 +957,8 @@ def iterate(level):
source_mappings, source_to_concepts, mappings_criteria, cascade_mappings, cascade_hierarchy,
include_mappings, False
)
cascaded_entries['concepts'] = list(cascaded_entries['concepts'])
cascaded_entries['concepts'] = list(
set(list(cascaded_entries['hierarchy_concepts']) + list(cascaded_entries['concepts'])))

concept.cascaded_entries = cascaded_entries
cascaded.append(concept.id)
Expand All @@ -977,15 +979,15 @@ def get_cascaded_resources( # pylint: disable=too-many-arguments
from core.mappings.models import Mapping
mappings = Mapping.objects.none()
concepts = Concept.objects.filter(id=self.id) if include_self else Concept.objects.none()
result = dict(concepts=concepts, mappings=mappings)
result = dict(concepts=concepts, mappings=mappings, hierarchy_concepts=Concept.objects.none())
mappings_criteria = mappings_criteria or Q()
if cascade_mappings and (source_mappings or source_to_concepts):
mappings = self.get_unidirectional_mappings().filter(mappings_criteria).order_by('map_type')
if include_mappings:
result['mappings'] = mappings
if source_to_concepts:
if cascade_hierarchy:
result['concepts'] |= self.child_concept_queryset()
result['hierarchy_concepts'] |= self.child_concept_queryset()
if mappings.exists():
result['concepts'] |= Concept.objects.filter(
id__in=mappings.values_list('to_concept_id', flat=True),
Expand Down

0 comments on commit 15c25cd

Please sign in to comment.