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

solution_py-tickets-and-orders_1 #557

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

Conversation

Vladkrit11
Copy link

No description provided.

Comment on lines 48 to 50
movie_session = (MovieSession.objects.prefetch_related("ticket_set").
get(id=movie_session_id))
tickets = movie_session.ticket_set.values("row", "seat")

Choose a reason for hiding this comment

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

Why do you start query from MovieSession, in this case you do 2 queries instead of 1

services/user.py Outdated
Comment on lines 40 to 45
if email:
user.email = email
if first_name:
user.first_name = first_name
if last_name:
user.last_name = last_name

Choose a reason for hiding this comment

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

Duplicate code, the same into create_user

Comment on lines 52 to 58
return [
{
"row": ticket["row"],
"seat": ticket["seat"]
}
for ticket in tickets
]

Choose a reason for hiding this comment

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

Suggested change
return [
{
"row": ticket["row"],
"seat": ticket["seat"]
}
for ticket in tickets
]
return tickets

Comment on lines 29 to 32
if username:
return (Order.objects.select_related("user").
filter(user__username=username))
return Order.objects.all()

Choose a reason for hiding this comment

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

Suggested change
if username:
return (Order.objects.select_related("user").
filter(user__username=username))
return Order.objects.all()
orders = Order.objects.select_related("user")
if username:
orders = orders.filter(user__username=username)
return orders

)


def get_orders(username: str = None) -> Order:

Choose a reason for hiding this comment

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

Does this function return Order?

Copy link

@Dimosphen1 Dimosphen1 left a comment

Choose a reason for hiding this comment

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

Several changes were requested.

movie.actors.set(actors_ids)

return movie
with transaction.atomic():

Choose a reason for hiding this comment

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

In case you apply transaction.atomic to the whole function body, you could use transaction.atomic as a decorator for a function.

date: str = None
) -> None:
order = Order.objects.create(
user=User.objects.get(

Choose a reason for hiding this comment

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

Use get_user_model() instead of User here and in other places where applicable as mentioned in the checklist.

)


def get_orders(username: str = None) -> QuerySet:

Choose a reason for hiding this comment

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

You could additionally specify that a QuerySet of Order is returned in the return type annotation.

Copy link

@Polyakiv-Andrey Polyakiv-Andrey left a comment

Choose a reason for hiding this comment

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

Good job!

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.

5 participants