Skip to content

Commit

Permalink
fix(history): add history serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Xenepix committed Oct 15, 2023
1 parent 3c32420 commit 11c3270
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions django_napse/api/histories/serializers/history_serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from rest_framework import serializers

from django_napse.core.models.histories.history import History, HistoryDataPoint, HistoryDataPointField


class HistorySerializer(serializers.Serializer):
data_points = HistoryDataPoint(many=True, read_only=True)

class Meta:
model = History
fields = ["data_points"]


class HistoryDataPointSerializer(serializers.Serializer):
fields = HistoryDataPointField(many=True, read_only=True)

class Meta:
model = HistoryDataPoint
fields = [
"fields",
]


class HistoryDataPointFieldSerializer(serializers.Serializer):
class Meta:
model = HistoryDataPointField
fields = [
"key",
"value",
"target_type",
]
read_only_fields = fields

0 comments on commit 11c3270

Please sign in to comment.