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 #556

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

Conversation

Molodoirockstar
Copy link

No description provided.

Comment on lines 14 to 37
with transaction.atomic():
user = User.objects.get(username=username)
order = Order.objects.create(
user=user,
)

if date:
order.created_at = date

order.save()

for ticket_data in tickets:
row = ticket_data["row"]
seat = ticket_data["seat"]
movie_session_id = ticket_data["movie_session"]

Ticket.objects.create(
order=order,
row=row,
seat=seat,
movie_session_id=movie_session_id
)

return order
Copy link

Choose a reason for hiding this comment

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

When you apply transaction.atomic() to the whole function body, it is a better choice to use it as a decorator instead of a context manager.

Copy link

@vsmutok vsmutok 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.

2 participants