-
Notifications
You must be signed in to change notification settings - Fork 715
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
Solution #720
base: master
Are you sure you want to change the base?
Solution #720
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on implementing the core functionalities! 🎉 While there are a few minor areas for improvement, such as ensuring naming consistency and adjusting the pagination settings, these do not critically impact the functionality of your code. Keep up the good work and consider the feedback for future enhancements! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
class OrderPagination(PageNumberPagination): | ||
page_size = 1 | ||
page_size_query_param = "page_size" | ||
max_page_size = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The max_page_size
is set to 1, which might be too restrictive for practical use cases. Consider increasing this value to allow more flexibility in the number of items per page.
tickets = TicketSerializer( | ||
many=True, | ||
read_only=False, | ||
allow_empty=False | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the OrderCreateSerializer
, the tickets
field uses TicketSerializer
with read_only=False
and allow_empty=False
. Ensure that the TicketSerializer
is capable of handling the input data correctly, especially if there are any nested relationships or specific validation requirements.
def create(self, validated_data): | ||
with transaction.atomic(): | ||
tickets_data = validated_data.pop("tickets") | ||
order = Order.objects.create(**validated_data) | ||
for ticket_data in tickets_data: | ||
Ticket.objects.create(order=order, **ticket_data) | ||
return order |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The create
method in OrderCreateSerializer
is correctly using transaction.atomic()
to ensure that the order and associated tickets are created atomically. However, consider adding validation to ensure that the tickets_data
is not empty before proceeding with the creation of the order.
@@ -6,7 +6,7 @@ | |||
ActorViewSet, | |||
CinemaHallViewSet, | |||
MovieViewSet, | |||
MovieSessionViewSet, | |||
MovieSessionViewSet, OrderSessionViewSet, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The OrderSessionViewSet
is registered in the router. Ensure that this is the correct name for the viewset, as it might be intended to be OrderViewSet
based on typical naming conventions. Verify the viewset name in the views file to ensure consistency.
return queryset | ||
|
||
|
||
class OrderSessionViewSet(viewsets.ModelViewSet): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class OrderSessionViewSet
might be incorrectly named. It is likely intended to be OrderViewSet
based on the context of handling orders. Verify the intended name and update it for consistency across the application.
No description provided.