👔(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:
@@ -145,9 +145,19 @@ class TemplateSerializer(BaseResourceSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Template
|
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"]
|
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
|
# pylint: disable=abstract-method
|
||||||
class DocumentGenerationSerializer(serializers.Serializer):
|
class DocumentGenerationSerializer(serializers.Serializer):
|
||||||
|
|||||||
Reference in New Issue
Block a user