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

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

Solution #875

wants to merge 2 commits into from

Conversation

pashawarganov
Copy link

No description provided.

db/models.py Outdated
f"(1, {self.movie_session.cinema_hall.seats_in_row})"
})

def save(self, *args, **kwargs) -> Callable:
Copy link

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

@@ -6,6 +7,7 @@
def get_movies(
genres_ids: list[int] = None,
actors_ids: list[int] = None,
title: str = None
Copy link

Choose a reason for hiding this comment

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

str or None

Comment on lines 52 to 53
Ticket.objects
.filter(movie_session_id=movie_session_id)
Copy link

@MNDonut MNDonut Sep 3, 2024

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

def create_order(
tickets: list[dict],
username: str,
date: datetime = None
Copy link

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

date: datetime = None
) -> Order:
with transaction.atomic():
order = Order.objects.create(user=User.objects.get(username=username))
Copy link

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

return order


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

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)
Copy link

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
Comment on lines 10 to 12
email: str = None,
first_name: str = None,
last_name: str = None
Copy link

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
Copy link

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? 👀

Copy link
Author

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
Comment on lines 38 to 42
username: str = None,
password: str = None,
email: str = None,
first_name: str = None,
last_name: str = None,
Copy link

Choose a reason for hiding this comment

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

annotation

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