-
Notifications
You must be signed in to change notification settings - Fork 857
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 #875
base: master
Are you sure you want to change the base?
Solution #875
Conversation
db/models.py
Outdated
f"(1, {self.movie_session.cinema_hall.seats_in_row})" | ||
}) | ||
|
||
def save(self, *args, **kwargs) -> Callable: |
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.
It's None actually, save doesn't return anything
services/movie.py
Outdated
@@ -6,6 +7,7 @@ | |||
def get_movies( | |||
genres_ids: list[int] = None, | |||
actors_ids: list[int] = None, | |||
title: str = None |
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.
str or None
services/movie_session.py
Outdated
Ticket.objects | ||
.filter(movie_session_id=movie_session_id) |
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.
Or reuse get_movie_session_by_id and use related_name to fetch tickets of this movie session. But this is ok as well
services/order.py
Outdated
def create_order( | ||
tickets: list[dict], | ||
username: str, | ||
date: datetime = None |
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.
datetime or None. Fix evewhere annotation
services/order.py
Outdated
date: datetime = None | ||
) -> Order: | ||
with transaction.atomic(): | ||
order = Order.objects.create(user=User.objects.get(username=username)) |
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.
Use get_user_model instead of using User explicitly because the purpose of AUTH_USER_MODEL is to not hardcode main model
services/order.py
Outdated
return order | ||
|
||
|
||
def get_orders(username: str = None) -> QuerySet: |
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.
str or None
for ticket in tickets | ||
] | ||
|
||
Ticket.objects.bulk_create(new_tickets) |
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.
I liked this approach :)
services/user.py
Outdated
email: str = None, | ||
first_name: str = None, | ||
last_name: str = None |
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.
Annotation
@@ -0,0 +1,65 @@ | |||
from __future__ import annotations | |||
from django.contrib.auth import get_user_model |
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.
But here you use get_user_model, isn't it strange? 👀
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.
Yes, that's because I had python 3.9. Now I have updated it)
services/user.py
Outdated
username: str = None, | ||
password: str = None, | ||
email: str = None, | ||
first_name: str = None, | ||
last_name: str = None, |
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.
annotation
No description provided.