Skip to content
Open
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
6 changes: 5 additions & 1 deletion backend/gsr_booking/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,11 @@ def retrieve(self, request, *args, **kwargs):
)

serializer = self.get_serializer(share_code.booking)
return Response(serializer.data)
user = share_code.booking.user
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code creates a nested response structure that's not consistent with the other endpoints. it's also good practice for the serializer to define what data gets returned. instead of manually wrapping it like this, an easier and cleaner approach would be to add owner_name directly to SharedGSRBookingSerializer as a field

return Response({
"owner_name": f"{user.first_name} {user.last_name}",
"booking": serializer.data
})

# create() is inherited from CreateModelMixin
# destroy() is inherited from DestroyModelMixin
Loading