👔(backend) add css and code in template serializer

We want to be able to update the css and code of
a template from the update endpoint.
This commit adds the css and code fields to the
TemplateSerializer.
This commit is contained in:
Anthony LC
2024-04-17 10:18:43 +02:00
committed by Anthony LC
parent 5074b271ad
commit faeb8d137b

View File

@@ -145,9 +145,19 @@ class TemplateSerializer(BaseResourceSerializer):
class Meta:
model = models.Template
fields = ["id", "title", "code_editor", "accesses", "abilities"]
fields = ["id", "title", "code_editor", "accesses", "abilities", "css", "code"]
read_only_fields = ["id", "accesses", "abilities"]
def to_representation(self, instance):
"""
Modify the output of serialization.
"""
representation = super().to_representation(instance)
# Remove 'css' and 'code' from the representation
representation.pop("css", None)
representation.pop("code", None)
return representation
# pylint: disable=abstract-method
class DocumentGenerationSerializer(serializers.Serializer):