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

first #657

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

first #657

wants to merge 10 commits into from

Conversation

egor250330
Copy link

No description provided.



class TicketRetrieveSerializer(TicketSerializer):
movie_session = MovieSessionListSerializer(many=False, read_only=True)

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

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

Copy link

@oliasymak24 oliasymak24 left a 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

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(",")]

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

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
Comment on lines 43 to 53
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)

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(",")]

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")

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")

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(",")]

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)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants