Skip to content

Commit

Permalink
Serialize result values
Browse files Browse the repository at this point in the history
  • Loading branch information
juuso-j committed May 13, 2024
1 parent 6ef0b02 commit fe292e9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions profiles/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ class Meta:


class PostalCodeResultSerializer(serializers.ModelSerializer):
result_topic_en = serializers.CharField(source="result.topic_en", read_only=True)
postal_code_string = serializers.CharField(
source="postal_code.postal_code", read_only=True
)
Expand All @@ -130,12 +129,16 @@ class Meta:
"postal_code_type",
"postal_code_type_string",
"result",
"result_topic_en",
"count",
]

def to_representation(self, instance):
representation = super().to_representation(instance)
results_topics = {
"fi": instance.result.value_fi,
"sv": instance.result.value_sv,
"en": instance.result.value_en,
}
representation["result_topics"] = results_topics
representation["count"] = blur_count(instance.count)
return representation

Expand Down

0 comments on commit fe292e9

Please sign in to comment.