Skip to content

Commit

Permalink
Update record serializing to handle None values
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbiggs committed Nov 14, 2024
1 parent 059d226 commit 95998ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions etna/records/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ def extract_references(self, value):
return []

def get_api_representation(self, value, context=None):
return {
"title": value.summary_title,
"iaid": value.iaid,
"reference_number": value.reference_number,
}
if value:
return {
"title": value.summary_title,
"iaid": value.iaid,
"reference_number": value.reference_number,
}
return None

class Meta:
icon = "archive"
Expand Down
12 changes: 7 additions & 5 deletions etna/records/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

class RecordSerializer(serializers.Serializer):
def to_representation(self, instance):
return {
"title": instance.summary_title,
"iaid": instance.iaid,
"reference_number": instance.reference_number,
}
if instance:
return {
"title": instance.summary_title,
"iaid": instance.iaid,
"reference_number": instance.reference_number,
}
return None

0 comments on commit 95998ca

Please sign in to comment.