-
Notifications
You must be signed in to change notification settings - Fork 636
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
first #657
base: master
Are you sure you want to change the base?
first #657
Conversation
|
||
|
||
class TicketRetrieveSerializer(TicketSerializer): | ||
movie_session = MovieSessionListSerializer(many=False, read_only=True) |
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.
False is a default value, thus you can remove it
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.
Good markm change this please
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.
Add annotations
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.
In create/update/delete function you don't need return anything
cinema/views.py
Outdated
genres_ids = [int(str_id) for str_id in genres.split(",")] | ||
queryset = queryset.filter(genres__id__in=genres_ids) | ||
if actors: | ||
actors_ids = [int(str_id) for str_id in actors.split(",")] |
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.
Code duplicate, put in function
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.
Please fix as requested
cinema/views.py
Outdated
actors = self.request.query_params.get("actors") | ||
genres = self.request.query_params.get("genres") | ||
title = self.request.query_params.get("title") | ||
if genres: | ||
genres_ids = [int(str_id) for str_id in genres.split(",")] | ||
queryset = queryset.filter(genres__id__in=genres_ids) | ||
if actors: | ||
actors_ids = [int(str_id) for str_id in actors.split(",")] | ||
queryset = queryset.filter(actors__id__in=actors_ids) | ||
if title: | ||
queryset = queryset.filter(title__icontains=title) |
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.
This part must be evaluated if self.actions == "list"
cinema/views.py
Outdated
genres_ids = [int(str_id) for str_id in genres.split(",")] | ||
queryset = queryset.filter(genres__id__in=genres_ids) | ||
if actors: | ||
actors_ids = [int(str_id) for str_id in actors.split(",")] |
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.
Please fix as requested
cinema/views.py
Outdated
def get_queryset(self): | ||
queryset = self.queryset.prefetch_related("genres", "actors") | ||
|
||
genres = self.request.query_params.get("genres") |
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.
you need to do filter by query params only on list action
cinema/views.py
Outdated
) | ||
) | ||
|
||
movie_id = self.request.query_params.get("movie") |
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.
same here - filtering is needed only on list action
title = self.request.query_params.get("title") | ||
|
||
if genres: | ||
genres_ids = [int(str_id) for str_id in genres.split(",")] |
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.
You didn't change previous comments
|
||
|
||
class TicketRetrieveSerializer(TicketSerializer): | ||
movie_session = MovieSessionListSerializer(many=False, read_only=True) |
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.
Good markm change this please
No description provided.