-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(history): add history serializer
- Loading branch information
Xenepix
committed
Oct 15, 2023
1 parent
3c32420
commit 11c3270
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
django_napse/api/histories/serializers/history_serializers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |