Coverage for backend/core/auxiliary/serializers/SolutionSerializer.py: 77%
13 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-11-06 23:27 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-11-06 23:27 +0000
1from rest_framework import serializers
2from drf_spectacular.utils import extend_schema_field
3from core.auxiliary.models.Solution import Solution
4from core.auxiliary.models.PropertyValue import PropertyValue
6class SolutionSerializer(serializers.ModelSerializer):
7 name = serializers.SerializerMethodField()
8 class Meta:
9 model = Solution
10 fields = '__all__'
12 def get_name(self, instance: Solution):
13 """
14 Returns a string with all the indexed items concatenated together. This is useful for e.g displaying keys on the graphs in the ui.
15 """
16 property_value : PropertyValue = instance.property
17 name = property_value.property.displayName
18 return name