Skip to content

Commit

Permalink
POST concepts | descriptions in api needs to be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Sep 14, 2020
1 parent 201e5f4 commit 645b2d2
Show file tree
Hide file tree
Showing 3 changed files with 418 additions and 3 deletions.
6 changes: 4 additions & 2 deletions core/concepts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,14 @@ def is_existing_in_parent(self):
@classmethod
def persist_new(cls, data, user=None, create_initial_version=True):
names = [
name if isinstance(name, LocalizedText) else LocalizedText.build(name) for name in data.pop('names', [])
name if isinstance(name, LocalizedText) else LocalizedText.build(
name
) for name in data.pop('names', []) or []
]
descriptions = [
desc if isinstance(desc, LocalizedText) else LocalizedText.build(
desc, 'description'
) for desc in data.pop('descriptions', [])
) for desc in data.pop('descriptions', []) or []
]
concept = Concept(**data)
concept.version = TEMP
Expand Down
2 changes: 1 addition & 1 deletion core/concepts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class ConceptDetailSerializer(ModelSerializer):
created_on = DateTimeField(source='created_at', read_only=True)
updated_on = DateTimeField(source='updated_at', read_only=True)
names = LocalizedNameSerializer(many=True)
descriptions = LocalizedDescriptionSerializer(many=True)
descriptions = LocalizedDescriptionSerializer(many=True, allow_null=True)
external_id = CharField(required=False, allow_blank=True)
concept_class = CharField(required=True)
datatype = CharField(required=True)
Expand Down

0 comments on commit 645b2d2

Please sign in to comment.