2022-08-19 10:35:05 +00:00
|
|
|
from rest_framework import serializers
|
|
|
|
|
2022-08-22 02:01:56 +00:00
|
|
|
from frog_api.models import Entry, Measure, Project, Version
|
2022-08-19 10:35:05 +00:00
|
|
|
|
|
|
|
|
2022-08-21 11:25:44 +00:00
|
|
|
class VersionSerializer(serializers.HyperlinkedModelSerializer):
|
2022-08-19 10:35:05 +00:00
|
|
|
class Meta:
|
2022-08-21 11:25:44 +00:00
|
|
|
model = Version
|
2022-08-19 10:35:05 +00:00
|
|
|
fields = ["slug", "name"]
|
|
|
|
|
|
|
|
|
2022-08-21 11:25:44 +00:00
|
|
|
class ProjectSerializer(serializers.HyperlinkedModelSerializer):
|
|
|
|
versions = VersionSerializer(many=True)
|
|
|
|
|
2022-08-19 10:35:05 +00:00
|
|
|
class Meta:
|
2022-08-21 11:25:44 +00:00
|
|
|
model = Project
|
|
|
|
fields = ["slug", "name", "versions"]
|
2022-08-19 10:35:05 +00:00
|
|
|
|
|
|
|
|
2022-08-22 02:01:56 +00:00
|
|
|
class MeasureSerializer(serializers.HyperlinkedModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Measure
|
|
|
|
fields = ["type", "value"]
|
|
|
|
|
|
|
|
|
2022-08-19 10:35:05 +00:00
|
|
|
class EntrySerializer(serializers.HyperlinkedModelSerializer):
|
2022-08-22 02:01:56 +00:00
|
|
|
measures = MeasureSerializer(many=True)
|
|
|
|
|
2022-08-19 10:35:05 +00:00
|
|
|
class Meta:
|
2022-08-20 03:33:23 +00:00
|
|
|
model = Entry
|
2022-08-19 10:35:05 +00:00
|
|
|
fields = [
|
|
|
|
"timestamp",
|
|
|
|
"git_hash",
|
2022-08-22 02:01:56 +00:00
|
|
|
"measures",
|
2022-08-19 10:35:05 +00:00
|
|
|
]
|
2022-08-21 11:25:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TerseEntrySerializer(serializers.HyperlinkedModelSerializer):
|
2022-08-22 02:01:56 +00:00
|
|
|
measures = MeasureSerializer(many=True)
|
|
|
|
|
2022-08-21 11:25:44 +00:00
|
|
|
class Meta:
|
|
|
|
model = Entry
|
|
|
|
fields = [
|
|
|
|
"timestamp",
|
2022-08-22 02:01:56 +00:00
|
|
|
"measures",
|
2022-08-21 11:25:44 +00:00
|
|
|
]
|