Coverage for backend/django/core/plots/PlotSerializer.py: 100%
23 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-07-22 05:22 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-07-22 05:22 +0000
1from core.serializer_base import StateOwnedModelSerializer
2from .Plot import Plot, Series
3from rest_framework import serializers
4from core.auxiliary.models import PropertyInfo, HistoricalValue
5from core.auxiliary.serializers.PropertyInfoSerializer import PropertyHistorySerializer
8# don't return all the property info, just the history
9class PropertyInfoHistorySerializer(StateOwnedModelSerializer):
10 history = PropertyHistorySerializer(many=True)
12 class Meta:
13 model = PropertyInfo
14 fields = ["key", "history"]
17class SeriesSerializer(StateOwnedModelSerializer):
18 x_data = PropertyInfoHistorySerializer(required=False, read_only=True, source="x")
19 y_data = PropertyInfoHistorySerializer(required=False, read_only=True, source="y")
21 class Meta:
22 model = Series
23 fields = "__all__"
24 extra_kwargs = {
25 "x": {"required": False},
26 "y": {"required": False}
27 }
30class PlotSerializer(StateOwnedModelSerializer):
31 series = SeriesSerializer(many=True, read_only=True)
33 class Meta:
34 model = Plot
35 fields = "__all__"
36 read_only_fields = ["id", "series"]