add fields to serializer

This commit is contained in:
ThePetrovich 2025-07-03 20:56:22 +08:00
parent 0925d87a00
commit 5af3b95c8d

View file

@ -13,9 +13,9 @@ class PredictionSerializer(serializers.ModelSerializer):
PROFILE_STANDARD = "standard_profile"
PROFILE_FLOAT = "float"
PROFILE_REVERSE = "reverse"
PROFILE_CUSTOM = "custom"
PROFILE_FLOAT = "float_profile"
PROFILE_REVERSE = "reverse_profile"
PROFILE_CUSTOM = "custom_profile"
LATEST_DATASET_KEYWORD = "latest"
SUPPORTED_PROFILES = [PROFILE_STANDARD, PROFILE_FLOAT, PROFILE_REVERSE, PROFILE_CUSTOM]
@ -38,6 +38,15 @@ class PredictionRequestSerializer(serializers.Serializer):
ascent_curve = serializers.CharField(required=False)
descent_curve = serializers.CharField(required=False)
interpolate = serializers.BooleanField(required=False, default=False)
start_point = serializers.PrimaryKeyRelatedField(
queryset=SavedPoint.objects.all(), required=False, allow_null=True
)
rate_profile = serializers.PrimaryKeyRelatedField(
queryset=SavedRateProfile.objects.all(), required=False, allow_null=True
)
template = serializers.PrimaryKeyRelatedField(
queryset=PreditctionTemplate.objects.all(), required=False, allow_null=True
)
def validate(self, data):
profile = data.get("profile", PROFILE_STANDARD)