From 773b4b0bc4ba5f67843c973447fe627cf330a2ce Mon Sep 17 00:00:00 2001 From: Ernesto Rico Schmidt <ernesto@helsinki.at> Date: Wed, 5 Apr 2023 18:36:53 -0400 Subject: [PATCH] Make ppoi updatable --- program/serializers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/program/serializers.py b/program/serializers.py index 34f7ad0e..f1165f1a 100644 --- a/program/serializers.py +++ b/program/serializers.py @@ -198,6 +198,7 @@ class HostLinkSerializer(serializers.ModelSerializer): class ImageSerializer(serializers.ModelSerializer): + ppoi = serializers.CharField(max_length=20) # PPOIField max_length thumbnails = serializers.SerializerMethodField() @staticmethod @@ -216,7 +217,6 @@ class ImageSerializer(serializers.ModelSerializer): read_only_fields = ( "height", "id", - "ppoi", "thumbnails", "width", ) @@ -224,6 +224,7 @@ class ImageSerializer(serializers.ModelSerializer): "alt_text", "credits", "image", + "ppoi", ) + read_only_fields def create(self, validated_data): @@ -237,9 +238,10 @@ class ImageSerializer(serializers.ModelSerializer): def update(self, instance, validated_data): """Update and return an existing Image instance, given the validated data.""" - # Only alt_text and credits can be updated. + # Only these fields can be updated. instance.alt_text = validated_data.get("alt_text", instance.alt_text) instance.credits = validated_data.get("credits", instance.credits) + instance.image.ppoi = validated_data.get("ppoi", instance.ppoi) instance.save() -- GitLab