-
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 #1078
base: master
Are you sure you want to change the base?
Solution #1078
Conversation
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.
Thank you for your hard work on this project! There are a few critical issues that need to be addressed before we can approve the pull request:
-
Return Type Annotations: The return type annotations for several functions in your service files are incorrect. Functions like
create_movie
,get_movie_by_id
,get_movies
,create_cinema_hall
,create_movie_session
,get_movie_session_by_id
,get_movies_sessions
, andupdate_movie_session
are annotated to returnstr
, but they should return instances of their respective models orQuerySet
objects. Correcting these annotations is crucial for maintaining code clarity and preventing potential runtime errors. -
Foreign Key Assignments: In your service functions, the
cinema_hall
andmovie
fields should be assigned instances ofCinemaHall
andMovie
, respectively, rather than their IDs. UseCinemaHall.objects.get(id=cinema_hall_id)
andMovie.objects.get(id=movie_id)
to retrieve the instances. This ensures that the foreign key relationships are correctly established. -
Related Name Conflicts: The
related_name
attributes for theactors
andgenres
fields in theMovie
model are set to"actors"
and"genres"
, which might conflict with Django's default related names. Consider using more descriptive names like"movies_as_actor"
and"movies_as_genre"
to avoid potential conflicts.
Once these issues are resolved, your code will be in great shape! Keep up the good work, and don't hesitate to reach out if you have any questions or need further assistance. 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review
button in the Reviewers tab.
"actors", | ||
models.ManyToManyField(related_name="actors", to="db.actor"), |
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.
The related_name
for the actors
field is set to 'actors'. This might conflict with the default related name Django generates for reverse lookups. Consider using a more specific name like 'movies_as_actor' to avoid potential conflicts.
"genres", | ||
models.ManyToManyField(related_name="genres", to="db.genre"), |
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.
The related_name
for the genres
field is set to 'genres'. This might conflict with the default related name Django generates for reverse lookups. Consider using a more specific name like 'movies_as_genre' to avoid potential conflicts.
db/models.py
Outdated
class Movie(models.Model): | ||
title = models.CharField(max_length=255) | ||
description = models.TextField(null=True) | ||
actors = models.ManyToManyField(Actor, related_name="actors") |
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.
The related_name
for the actors
field is set to 'actors'. This could conflict with the default related name Django generates for reverse lookups. Consider using a more specific name like 'movies_as_actor' to avoid potential conflicts.
db/models.py
Outdated
title = models.CharField(max_length=255) | ||
description = models.TextField(null=True) | ||
actors = models.ManyToManyField(Actor, related_name="actors") | ||
genres = models.ManyToManyField(Genre, related_name="genres") |
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.
The related_name
for the genres
field is set to 'genres'. This could conflict with the default related name Django generates for reverse lookups. Consider using a more specific name like 'movies_as_genre' to avoid potential conflicts.
hall_name: str, | ||
hall_rows: int, | ||
hall_seats_in_row: int | ||
) -> str: |
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.
The return type of the create_cinema_hall
function is specified as str
, but it should be CinemaHall
since the function returns an instance of the CinemaHall
model.
services/movie_session.py
Outdated
cinema_hall=cinema_hall_id, | ||
movie=movie_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.
The cinema_hall
and movie
fields should be assigned CinemaHall
and Movie
instances, respectively, not their IDs. Consider using CinemaHall.objects.get(id=cinema_hall_id)
and Movie.objects.get(id=movie_id)
to retrieve the instances.
services/movie_session.py
Outdated
) | ||
|
||
|
||
def get_movies_sessions(session_date: str = None) -> str: |
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.
The return type of the get_movies_sessions
function is specified as str
, but it should be QuerySet
or list
depending on the desired return type, as the function returns a queryset of MovieSession
instances.
return query | ||
|
||
|
||
def get_movie_session_by_id(movie_session_id: int) -> str: |
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.
The return type of the get_movie_session_by_id
function is specified as str
, but it should be MovieSession
since the function returns an instance of the MovieSession
model.
show_time: str = None, | ||
movie_id: int = None, | ||
cinema_hall_id: int = None | ||
) -> str: |
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.
The return type of the update_movie_session
function is specified as str
, but it should be MovieSession
since the function returns an instance of the MovieSession
model.
services/movie_session.py
Outdated
session.movie = movie_id | ||
if cinema_hall_id: | ||
session.cinema_hall = cinema_hall_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.
The movie
and cinema_hall
fields should be assigned Movie
and CinemaHall
instances, respectively, not their IDs. Consider using Movie.objects.get(id=movie_id)
and CinemaHall.objects.get(id=cinema_hall_id)
to retrieve the instances.
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.
Great job on your progress! 🎉 While there are some areas that need improvement, your work is on the right track. Here are the key points to address:
-
Return Type Annotations: Several functions have incorrect return type annotations. Ensure that:
create_movie
,get_movie_by_id
, andget_movies
return instances ofMovie
or aQuerySet
ofMovie
instances.create_cinema_hall
returns an instance ofCinemaHall
.create_movie_session
,get_movie_session_by_id
,get_movies_sessions
, andupdate_movie_session
return instances ofMovieSession
or aQuerySet
ofMovieSession
instances.
-
Foreign Key Assignments: When creating a
Movie
, use theset
method to assignactors
andgenres
after the movie object is created, rather than assigningactors_ids
andgenres_ids
directly. -
Related Name Conflicts: You've updated the
related_name
attributes for theactors
andgenres
fields in theMovie
model to"movies_as_actor"
and"movies_as_genre"
, which is a good practice to avoid conflicts. -
Parameter Types: Ensure that the
movie_show_time
andshow_time
parameters are of typedatetime
to match theDateTimeField
in theMovieSession
model. -
Unrelated Files: Consider removing unrelated files like
settings.py
from the submission to keep the focus on the task requirements.
Keep up the good work, and make sure to address these issues in future iterations to enhance the functionality and maintainability of your code. Your dedication to learning and improving is commendable! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
("title", models.CharField(max_length=255)), | ||
( | ||
"actors", | ||
models.ManyToManyField(related_name="actors", to="db.actor"), |
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.
The related_name
for the actors
field is set to "actors", which might conflict with Django's default related names. Consider using a more descriptive name like "movies_as_actor".
), | ||
( | ||
"genres", | ||
models.ManyToManyField(related_name="genres", to="db.genre"), |
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.
The related_name
for the genres
field is set to "genres", which might conflict with Django's default related names. Consider using a more descriptive name like "movies_as_genre".
hall_name: str, | ||
hall_rows: int, | ||
hall_seats_in_row: int | ||
) -> str: |
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.
The return type annotation for create_cinema_hall
is incorrect. It should return an instance of CinemaHall
, not str
. Update the return type annotation to CinemaHall
.
from db.models import Genre, Actor, Movie | ||
|
||
|
||
def get_movies(genres_ids: list = None, actors_ids: list = None) -> str: |
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.
The return type annotation for get_movies
is incorrect. It should return a QuerySet
of Movie
instances, not str
. Update the return type annotation accordingly.
return query.distinct() | ||
|
||
|
||
def get_movie_by_id(movie_id: int) -> str: |
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.
The return type annotation for get_movie_by_id
is incorrect. It should return an instance of Movie
, not str
. Update the return type annotation accordingly.
services/movie_session.py
Outdated
movie=movie, | ||
) | ||
|
||
def get_movies_sessions(session_date: str = None) -> str: |
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.
The return type annotation for get_movies_sessions
is incorrect. It should return a QuerySet
of MovieSession
instances, not str
. Update the return type annotation accordingly.
return query | ||
|
||
|
||
def get_movie_session_by_id(movie_session_id: int) -> str: |
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.
The return type annotation for get_movie_session_by_id
is incorrect. It should return an instance of MovieSession
, not str
. Update the return type annotation accordingly.
show_time: str = None, | ||
movie_id: int = None, | ||
cinema_hall_id: int = None | ||
) -> str: |
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.
The return type annotation for update_movie_session
is incorrect. It should return an instance of MovieSession
, not str
. Update the return type annotation accordingly.
services/movie_session.py
Outdated
|
||
|
||
def create_movie_session( | ||
movie_show_time: str, |
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.
The movie_show_time
parameter should be of type datetime
instead of str
to match the DateTimeField
in the MovieSession
model.
services/movie_session.py
Outdated
|
||
def update_movie_session( | ||
session_id: int, | ||
show_time: 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.
The show_time
parameter should be of type datetime
instead of str
to match the DateTimeField
in the MovieSession
model.
No description provided.