👔(backend) display css and code in template endpoint
We would like to duplicate a template from the frontend. For that we need to access the css and code of the template. So we add the css and code to the template endpoint.
This commit is contained in:
@@ -157,16 +157,6 @@ class TemplateSerializer(BaseResourceSerializer):
|
||||
]
|
||||
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):
|
||||
|
||||
@@ -133,7 +133,7 @@ def test_api_documents_retrieve_authenticated_related_direct():
|
||||
"id": str(document.id),
|
||||
"title": document.title,
|
||||
"abilities": document.get_abilities(user),
|
||||
'is_public': document.is_public,
|
||||
"is_public": document.is_public,
|
||||
}
|
||||
|
||||
|
||||
@@ -247,7 +247,7 @@ def test_api_documents_retrieve_authenticated_related_team_members(
|
||||
"id": str(document.id),
|
||||
"title": document.title,
|
||||
"abilities": document.get_abilities(user),
|
||||
'is_public': False,
|
||||
"is_public": False,
|
||||
}
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ def test_api_documents_retrieve_authenticated_related_team_administrators(
|
||||
"id": str(document.id),
|
||||
"title": document.title,
|
||||
"abilities": document.get_abilities(user),
|
||||
'is_public': False,
|
||||
"is_public": False,
|
||||
}
|
||||
|
||||
|
||||
@@ -445,5 +445,5 @@ def test_api_documents_retrieve_authenticated_related_team_owners(
|
||||
"id": str(document.id),
|
||||
"title": document.title,
|
||||
"abilities": document.get_abilities(user),
|
||||
'is_public': False,
|
||||
"is_public": False,
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ def test_api_templates_retrieve_anonymous_public():
|
||||
"title": template.title,
|
||||
"code_editor": {},
|
||||
"is_public": True,
|
||||
"code": template.code,
|
||||
"css": template.css,
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +75,8 @@ def test_api_templates_retrieve_authenticated_unrelated_public():
|
||||
"title": template.title,
|
||||
"code_editor": {},
|
||||
"is_public": True,
|
||||
"code": template.code,
|
||||
"css": template.css,
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +143,8 @@ def test_api_templates_retrieve_authenticated_related_direct():
|
||||
"abilities": template.get_abilities(user),
|
||||
"code_editor": {},
|
||||
"is_public": template.is_public,
|
||||
"code": template.code,
|
||||
"css": template.css,
|
||||
}
|
||||
|
||||
|
||||
@@ -254,6 +260,8 @@ def test_api_templates_retrieve_authenticated_related_team_members(
|
||||
"abilities": template.get_abilities(user),
|
||||
"code_editor": {},
|
||||
"is_public": False,
|
||||
"code": template.code,
|
||||
"css": template.css,
|
||||
}
|
||||
|
||||
|
||||
@@ -351,6 +359,8 @@ def test_api_templates_retrieve_authenticated_related_team_administrators(
|
||||
"abilities": template.get_abilities(user),
|
||||
"code_editor": {},
|
||||
"is_public": False,
|
||||
"code": template.code,
|
||||
"css": template.css,
|
||||
}
|
||||
|
||||
|
||||
@@ -452,4 +462,6 @@ def test_api_templates_retrieve_authenticated_related_team_owners(
|
||||
"abilities": template.get_abilities(user),
|
||||
"code_editor": {},
|
||||
"is_public": False,
|
||||
"code": template.code,
|
||||
"css": template.css,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user