-
Notifications
You must be signed in to change notification settings - Fork 1k
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 #1093
base: master
Are you sure you want to change the base?
solution #1093
Changes from 1 commit
39311c7
4866b8c
f7a0d33
aaa1cab
a0ee413
e0c6dab
48f361b
e110afa
96e15a7
90d2f5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from db.models import CinemaHall | ||
from django.db.models import QuerySet | ||
|
||
|
||
def get_cinema_halls() -> QuerySet: | ||
return CinemaHall.objects.all() | ||
|
||
|
||
def create_cinema_hall(hall_name: str, | ||
hall_rows: int, | ||
hall_seats_in_row: int) -> CinemaHall: | ||
return CinemaHall(hall_name, | ||
hall_rows, | ||
hall_seats_in_row) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from db.models import Movie | ||
from django.db.models import QuerySet | ||
|
||
|
||
def get_movies(genres_ids: list = None, /, | ||
actors_ids: list = None) -> QuerySet: | ||
movies = Movie.objects.all() | ||
if genres_ids: | ||
movies.filter(genres__in=genres_ids) | ||
if actors_ids: | ||
movies.filter(actors__in=actors_ids) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
return movies | ||
|
||
|
||
def get_movie_by_id(movie_id) -> Movie: | ||
return Movie.objects.filter(id=movie_id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
|
||
def create_movie(movie_title: str, movie_description: str, | ||
genres_ids: list = None, | ||
actors_ids: list = None) -> Movie: | ||
new_movie = Movie.objects.create(title=movie_title, | ||
description=movie_description) | ||
if genres_ids: | ||
new_movie.gernes.set(genres_ids) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a typo here: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a typo in the |
||
if actors_ids: | ||
new_movie.actors.set(actors_ids) | ||
|
||
return new_movie |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from db.models import MovieSession | ||
from datetime import datetime | ||
from django.db.models import QuerySet | ||
|
||
|
||
def create_movie_session(movie_show_time: datetime, | ||
movie_id: int, | ||
cinema_hall_id: int) -> MovieSession: | ||
return MovieSession.objects.create( | ||
show_time=movie_show_time, movie_id=movie_id, | ||
cinema_hall_id=cinema_hall_id) | ||
|
||
|
||
def get_movies_sessions(session_date: datetime.date = None) -> QuerySet: | ||
sessions_list = MovieSession.objecta.all() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a typo here: |
||
if session_date: | ||
sessions_list.filter(show_time__date=session_date) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
return sessions_list | ||
|
||
|
||
def get_movie_session_by_id(movie_session_id: int) -> MovieSession: | ||
return MovieSession.objects.get(id=movie_sessin_id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a typo here: |
||
|
||
|
||
def update_movie_session(session_id: int, | ||
show_time: datetime = None, | ||
movie_id: int = None, | ||
cinema_hall_id: int = None) -> MovieSession: | ||
movie_session = MovieSession.objects.get(id=session_id) | ||
if show_time: | ||
movie_session.show_time = show_time | ||
if movie_id: | ||
movie_session.movie_id = movie_id | ||
if cinema_hall_id: | ||
movie_session.cinema_hall_id = cinema_hall_id | ||
|
||
movie_session.save() | ||
return 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.
There is a typo here:
gerne
should begenre
. This will cause an error when trying to access this field.