-
Notifications
You must be signed in to change notification settings - Fork 858
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
implemented tickets and orders architecture #829
base: master
Are you sure you want to change the base?
Conversation
db/models.py
Outdated
from django.db import models | ||
from django.db.models import UniqueConstraint | ||
|
||
import settings |
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 better to use
from django.conf import settings
that will import django settings because you may have a folder named "settings"
db/models.py
Outdated
to=MovieSession, on_delete=models.CASCADE, related_name="tickets") | ||
order = models.ForeignKey( | ||
to=Order, on_delete=models.CASCADE, related_name="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.
we don't add multiple parameters on the same line.
Either they are on the same lvl that ( bracket or 1 parameter - 1 line
services/movie.py
Outdated
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.
you didn't annotate None type
services/movie.py
Outdated
genres_ids: list = None, | ||
actors_ids: list = 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.
fix annotation
services/movie_session.py
Outdated
show_time: str = None, | ||
movie_id: int = None, | ||
cinema_hall_id: int = 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
services/order.py
Outdated
Ticket.objects.create(row=ticket["row"], seat=ticket["seat"], | ||
movie_session_id=ticket["movie_session"], | ||
order=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.
fix formatting. parameters should have the same indentation
services/user.py
Outdated
if first_name: | ||
user.first_name = first_name | ||
else: | ||
user.first_name = "" |
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 user.first_name = first_name or ""
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.
fix annotation
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.
fix annotation
…d annotations and formatting
services/movie.py
Outdated
if genres_ids: | ||
movie.genres.set(genres_ids) | ||
if actors_ids: | ||
movie.actors.set(actors_ids) | ||
|
||
return 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.
You don’t need to return
anything in create/update/delete methods, check everywhere
services/movie.py
Outdated
actors_ids: list[int] = None, | ||
genres_ids: list[int] | None = None, | ||
actors_ids: list[int] | None = None, | ||
title: str | None = 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.
specify what kind of data this queryset contains
services/movie_session.py
Outdated
show_time=movie_show_time, | ||
movie_id=movie_id, | ||
cinema_hall_id=cinema_hall_id, | ||
) | ||
|
||
|
||
def get_movies_sessions(session_date: str = None) -> QuerySet: | ||
def get_movies_sessions(session_date: str | None = 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.
specify what kind of data this queryset contains
services/movie_session.py
Outdated
@@ -42,3 +45,9 @@ def update_movie_session( | |||
|
|||
def delete_movie_session_by_id(session_id: int) -> None: | |||
MovieSession.objects.get(id=session_id).delete() |
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.
follow DRY and use get_movie_sessions
services/order.py
Outdated
def create_order( | ||
tickets: list[dict], | ||
username: str, | ||
date: 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/order.py
Outdated
) | ||
|
||
|
||
def get_orders(username: str = None) -> QuerySet[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.
str or None
services/user.py
Outdated
with transaction.atomic(): | ||
if password: | ||
user.set_password(password) |
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.
do you think only password can cause an error?
What if you get incorrect email like someemail.com?
Or the length of first_name will be > than max_length of this field?
services/user.py
Outdated
with transaction.atomic(): | ||
user.set_password(password) | ||
user.save() |
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.
do you think only password can cause an error?
What if you get incorrect email like someemail.com?
Or the length of first_name will be > than max_length of this field?
No description provided.