Skip to content

Commit

Permalink
fix: 500 error by cover_letter
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis-Shtanskiy committed Jan 6, 2025
1 parent 93d8703 commit 5454848
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/backend/api/v1/profile/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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


Expand Down
32 changes: 21 additions & 11 deletions src/backend/api/v1/projects/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 5454848

Please sign in to comment.