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: documents in registration response for all registration types #420

Merged
merged 1 commit into from
Dec 26, 2024
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
2 changes: 1 addition & 1 deletion strr-api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "strr-api"
version = "0.0.31"
version = "0.0.32"
description = ""
authors = ["thorwolpert <thor@wolpert.ca>"]
license = "BSD 3-Clause"
Expand Down
25 changes: 13 additions & 12 deletions strr-api/src/strr_api/responses/RegistrationSerializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ def serialize(cls, registration: Registration):
"registration_number": registration.registration_number,
}

documents = []
if registration.documents:
for doc in registration.documents:
documents.append(
{
"fileKey": doc.path,
"fileName": doc.file_name,
"fileType": doc.file_type,
"documentType": doc.document_type,
}
)
registration_data["documents"] = documents

if registration.registration_type == RegistrationType.HOST.value:
RegistrationSerializer.populate_host_registration_details(registration_data, registration)

Expand Down Expand Up @@ -169,18 +182,6 @@ def populate_platform_registration_details(cls, registration_data: dict, registr
@classmethod
def populate_host_registration_details(cls, registration_data: dict, registration: Registration):
"""Populates host registration details into response object."""
documents = []
if registration.documents:
for doc in registration.documents:
documents.append(
{
"fileKey": doc.path,
"fileName": doc.file_name,
"fileType": doc.file_type,
"documentType": doc.document_type,
}
)
registration_data["documents"] = documents

primary_property_contact = list(filter(lambda x: x.is_primary is True, registration.rental_property.contacts))[
0
Expand Down
Loading