Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 500 error by cover_letter #399

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading