diff --git a/src/backend/api/v1/profile/serializers.py b/src/backend/api/v1/profile/serializers.py index 6b96bb0..f0b7ab0 100644 --- a/src/backend/api/v1/profile/serializers.py +++ b/src/backend/api/v1/profile/serializers.py @@ -214,7 +214,7 @@ def to_representation(self, profile): ): for contact_field in ["phone_number", "telegram_nick", "email"]: data[contact_field] = None - data["about"] = html.unescape(data["about"]) + data["about"] = html.unescape(data["about"]) if data["about"] else "" return data @@ -241,7 +241,7 @@ class Meta(BaseProfileSerializer.Meta): def to_representation(self, instance): rep = super().to_representation(instance) - rep["about"] = html.unescape(rep["about"]) + rep["about"] = html.unescape(rep["about"]) if rep["about"] else "" return rep diff --git a/src/backend/api/v1/projects/serializers.py b/src/backend/api/v1/projects/serializers.py index 292c7a4..8d8250a 100644 --- a/src/backend/api/v1/projects/serializers.py +++ b/src/backend/api/v1/projects/serializers.py @@ -189,7 +189,9 @@ def get_unique_project_participants_skills(self, obj) -> list[Any]: def to_representation(self, instance): rep = super().to_representation(instance) - rep["description"] = html.unescape(rep["description"]) + rep["description"] = ( + html.unescape(rep["description"]) if rep["description"] else "" + ) return rep @@ -377,7 +379,9 @@ class Meta: def to_representation(self, instance): rep = super().to_representation(instance) - rep["cover_letter"] = html.unescape(rep["cover_letter"]) + rep["cover_letter"] = ( + html.unescape(rep["cover_letter"]) if rep["cover_letter"] else "" + ) return rep def get_position(self, obj) -> str: @@ -577,7 +581,9 @@ class Meta(BaseParticipationRequestSerializer.Meta): def to_representation(self, instance): rep = super().to_representation(instance) - rep["cover_letter"] = html.unescape(rep["cover_letter"]) + rep["cover_letter"] = ( + html.unescape(rep["cover_letter"]) if rep["cover_letter"] else "" + ) return rep def get_request_status(self, obj) -> str: @@ -601,10 +607,12 @@ def get_request_status(self, obj) -> str: # "created", # ) -# def to_representation(self, instance): -# rep = super().to_representation(instance) -# rep["cover_letter"] = html.unescape(rep["cover_letter"]) -# return rep +# def to_representation(self, instance): +# rep = super().to_representation(instance) +# rep["cover_letter"] = ( +# html.unescape(rep["cover_letter"]) if rep["cover_letter"] else "" +# ) +# return rep class WriteParticipationRequestAnswerSerializer( @@ -679,10 +687,12 @@ def update(self, instance, validated_data) -> ParticipationRequest: # "author", # ) -# def to_representation(self, instance): -# rep = super().to_representation(instance) -# rep["cover_letter"] = html.unescape(rep["cover_letter"]) -# return rep +# def to_representation(self, instance): +# rep = super().to_representation(instance) +# rep["cover_letter"] = ( +# html.unescape(rep["cover_letter"]) if rep["cover_letter"] else "" +# ) +# return rep class WriteInvitationToProjectSerializer(