Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed May 1, 2024
1 parent e194a64 commit 6d89a3b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 3 additions & 4 deletions core/collections/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def validate(self, reference):
return errors
if self.is_openmrs_schema and self.expansion_uri:
if reference._concepts is None or reference._concepts.count() == 0: # pylint: disable=protected-access
return
return None
for concept in reference._concepts: # pylint: disable=protected-access
errors1 = self.check_concept_uniqueness_in_collection_and_locale_by_name_attribute(
concept, attribute='type__in', value=LOCALES_FULLY_SPECIFIED,
Expand All @@ -240,7 +240,7 @@ def check_concept_uniqueness_in_collection_and_locale_by_name_attribute(
):
other_concepts_in_collection = self.expansion.concepts
if not other_concepts_in_collection.exists():
return
return False

errors = []
matching_names_in_concept = {}
Expand Down Expand Up @@ -296,8 +296,7 @@ def add_references(self, references, user=None, _async=False):
if reference_errors:
errors[reference.expression] = reference_errors
continue
else:
reference.save()
reference.save()
except Exception as ex:
errors[reference.expression] = ex.messages if hasattr(ex, 'messages') else ex
continue
Expand Down
9 changes: 6 additions & 3 deletions core/collections/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,17 @@ def test_validate_openmrs_schema_duplicate_locale_type(self):
concept2.uri: {
'errors': [
{
'description': 'Concept fully specified name must be unique for same collection and locale.',
'description': 'Concept fully specified name must be unique for same collection and '
'locale.',
'conflicting_concept_url': concept1.uri,
'conflicting_concept_name': concept1.display_name,
'conflicting_name_url': f"{concept1.uri}names/{en_locale.id}/",
'conflicting_name': en_locale.name,
'conflicting_references': [concept1_reference.uri]
},
{
'description': 'Concept fully specified name must be unique for same collection and locale.',
'description': 'Concept fully specified name must be unique for same collection and '
'locale.',
'conflicting_concept_url': concept1.uri,
'conflicting_concept_name': concept1.display_name,
'conflicting_name_url': f"{concept1.uri}names/{ch_locale.id}/",
Expand Down Expand Up @@ -305,7 +307,8 @@ def test_validate_openmrs_schema_matching_name_locale(self):
concept2.uri: {
'errors': [
{
'description': 'Concept fully specified name must be unique for same collection and locale.',
'description': 'Concept fully specified name must be unique for same collection and '
'locale.',
'conflicting_concept_url': concept2.uri,
'conflicting_concept_name': 'name',
'conflicting_name_url': f'{concept2.uri}names/{en_locale1.id}/',
Expand Down

0 comments on commit 6d89a3b

Please sign in to comment.