-
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
eeettt5 #530
base: master
Are you sure you want to change the base?
eeettt5 #530
Conversation
.run/pytest in test_main.py.run.xml
Outdated
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.
Remove this file, and folder
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.
???
db/models.py
Outdated
] | ||
|
||
def __str__(self) -> str: | ||
return f"Matrix 2019-08-19 20:30:00 (row: {self.row}, seat: {self.seat})" |
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.
Why matrix and date hardcoded?
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.
Not fixed
services/movie.py
Outdated
from db.models import Movie | ||
|
||
|
||
def get_movies( | ||
genres_ids: list[int] = None, | ||
actors_ids: list[int] = None, | ||
title=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.
add type annotations
services/movie.py
Outdated
@@ -15,13 +16,18 @@ def get_movies( | |||
if actors_ids: | |||
queryset = queryset.filter(actors__id__in=actors_ids) | |||
|
|||
if title: | |||
# фільтрувати фільми за назвою, якщо аргумент `title` переданий | |||
return Movie.objects.filter(title__icontains=title) |
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.
Why you do return this? And do not use already filtered queryset
services/movie_session.py
Outdated
tickets = Ticket.objects.filter(movie_session_id=movie_session_id) | ||
for ticket in tickets: | ||
taken_seats.append({"row": ticket.row, "seat": ticket.seat}) | ||
return taken_seats |
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.
Add empty line
services/order.py
Outdated
for ticket_data in tickets: | ||
row = ticket_data.get("row") | ||
seat = ticket_data.get("seat") | ||
movie_session = MovieSession.objects.get(pk=1) |
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.
Why do you use pk=1? Also .get redundant here
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.
Not fixed why pk=1???
services/order.py
Outdated
if username is not None: | ||
return Order.objects.filter(user__username=username).order_by("created_at") | ||
elif username is None: | ||
return Order.objects.all().order_by("-created_at") |
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 just one if here
services/user.py
Outdated
user.last_name = last_name | ||
user.save() | ||
return user | ||
except User.DoesNotExist: |
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.
This is not possible
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.
Remove try-except!!!
services/user.py
Outdated
try: | ||
user = User.objects.get(id=user_id) | ||
except User.DoesNotExist: |
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_object_or_404
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.
Not fixed!
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 it
перевір виконання цього завдання по даній адресі #537 (comment) |
перед тим як закинути на github виконане завдання я не побачив твої зауваження, тому якщо можна я їх виправлю після твоїх зауважень до #537 (comment) |
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.
Comments are not fixed
.run/pytest in test_main.py.run.xml
Outdated
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.
???
db/models.py
Outdated
@@ -49,4 +54,56 @@ class MovieSession(models.Model): | |||
) | |||
|
|||
def __str__(self) -> str: | |||
return f"{self.movie.title} {str(self.show_time)}" | |||
return f"{self.movie.title} {str(self.show_time)} {self.cinema_hall.rows} {self.cinema_hall.seats_in_row}" |
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.
return f"{self.movie.title} {str(self.show_time)} {self.cinema_hall.rows} {self.cinema_hall.seats_in_row}" | |
return f"{self.movie.title} {self.show_time} {self.cinema_hall.rows} {self.cinema_hall.seats_in_row}" |
db/models.py
Outdated
] | ||
|
||
def __str__(self) -> str: | ||
return f"Matrix 2019-08-19 20:30:00 (row: {self.row}, seat: {self.seat})" |
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.
Not fixed
db/models.py
Outdated
class User(AbstractUser): | ||
USERNAME_FIELD = "username" | ||
REQUIRED_FIELDS = [] | ||
pass |
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.
remove pass
db/models.py
Outdated
|
||
|
||
class User(AbstractUser): | ||
USERNAME_FIELD = "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.
this is by default the same
services/movie.py
Outdated
@@ -15,13 +16,17 @@ def get_movies( | |||
if actors_ids: | |||
queryset = queryset.filter(actors__id__in=actors_ids) | |||
|
|||
if title: | |||
return queryset.filter(title__icontains=title) |
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.
Why do you return here???
return queryset.filter(title__icontains=title) | |
queryset = queryset.filter(title__icontains=title) |
services/order.py
Outdated
for ticket_data in tickets: | ||
row = ticket_data.get("row") | ||
seat = ticket_data.get("seat") | ||
movie_session = MovieSession.objects.get(pk=1) |
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.
Not fixed why pk=1???
services/order.py
Outdated
date: datetime = None | ||
) -> None: | ||
user, created = User.objects.get_or_create(username=username) | ||
order, created = Order.objects.get_or_create(user=user) |
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.
order, created = Order.objects.get_or_create(user=user) | |
order = Order.objects.create(user) |
One use can have many orders
services/order.py
Outdated
if username is not None: | ||
return Order.objects.filter( | ||
user__username=username).order_by("created_at" | ||
) | ||
elif username is None: | ||
return Order.objects.all().order_by("-created_at") |
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.
if username is not None: | |
return Order.objects.filter( | |
user__username=username).order_by("created_at" | |
) | |
elif username is None: | |
return Order.objects.all().order_by("-created_at") | |
orders = Order.objects.all() | |
if username is not None: | |
orders = orders.filter(user__username=username) | |
return orders.order_by("-created_at") |
services/order.py
Outdated
ticket.save() | ||
|
||
|
||
def get_orders(username: str = None) -> list: |
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 returns QuerySet, not list
services/user.py
Outdated
user.last_name = last_name | ||
user.save() | ||
return user | ||
except User.DoesNotExist: |
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.
Remove try-except!!!
services/user.py
Outdated
try: | ||
user = User.objects.get(id=user_id) | ||
except User.DoesNotExist: |
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.
Not fixed!
services/user.py
Outdated
try: | ||
user = User.objects.get(id=user_id) | ||
except User.DoesNotExist: |
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 it
services/order.py
Outdated
ticket.save() | ||
|
||
|
||
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.
def get_orders(username: str = None) -> QuerySet: | |
def get_orders(username: str = None) -> QuerySet[Order]: |
services/order.py
Outdated
username: str, | ||
date: datetime = None | ||
) -> None: | ||
user, created = User.objects.get_or_create(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.
Why do you create user? Use just get
services/order.py
Outdated
for ticket_data in tickets: | ||
row = ticket_data.get("row") | ||
seat = ticket_data.get("seat") | ||
movie_session = MovieSession.objects.filter().first() |
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.
Why do you use .filter(). Also this line is redundant
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.
this line redundant
services/order.py
Outdated
ticket, created = Ticket.objects.get_or_create( | ||
row=row, | ||
seat=seat, | ||
movie_session=movie_session, |
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.
movie_session=movie_session, | |
movie_session_id=and here id of movie session, |
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.
поясни, що означає "movie_session_id=and here id of movie session,"
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.
movie_session=movie_session, | |
movie_session_id=ticket_data["movie_session"], |
db/models.py
Outdated
|
||
def __str__(self) -> str : | ||
return ( | ||
f"{Movie.objects.first()} {self.movie_session.show_time} " # noqa |
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.
Why do you use Movie.objects.first() here?
services/order.py
Outdated
ticket, created = Ticket.objects.get_or_create( | ||
row=row, | ||
seat=seat, | ||
movie_session=movie_session, |
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.
movie_session=movie_session, | |
movie_session_id=ticket_data["movie_session"], |
services/order.py
Outdated
for ticket_data in tickets: | ||
row = ticket_data.get("row") | ||
seat = ticket_data.get("seat") | ||
movie_session = MovieSession.objects.filter().first() |
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.
this line redundant
No description provided.