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

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

Solution #1062

wants to merge 4 commits into from

Conversation

4ikkamony
Copy link

No description provided.

Copy link

@dottfmar dottfmar left a comment

Choose a reason for hiding this comment

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

Well done!

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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. Specifically, the related_name for the cinema_hall field in the MovieSession model is misleading and should be changed to something more descriptive like 'sessions'. Additionally, the get_movie_by_id and get_movie_session_by_id functions should handle potential DoesNotExist exceptions more gracefully, perhaps by using get_object_or_404 if these functions are used in views. Once these issues are resolved, your code will be in great shape! Keep up the great work! 💪

✨ 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.

db/models.py Outdated
Comment on lines 50 to 53
cinema_hall = models.ForeignKey(
"db.CinemaHall",
on_delete=models.CASCADE,
related_name="cinema_halls"

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 cinema_hall field in the MovieSession model is set to 'cinema_halls'. This might be misleading because it suggests a reverse relation from CinemaHall to MovieSession instances. Consider changing it to something more descriptive like 'sessions' to better reflect the relationship.

Comment on lines +28 to +29
def get_movie_by_id(movie_id: int) -> Movie:
return Movie.objects.get(id=movie_id)

Choose a reason for hiding this comment

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

The get_movie_by_id function uses Movie.objects.get(id=movie_id), which will raise a DoesNotExist exception if no Movie with the given ID exists. Consider using get_object_or_404 from Django shortcuts if this function is used in a view, or handle the exception appropriately if used elsewhere.

Comment on lines +28 to +29
def get_movie_session_by_id(movie_session_id: int) -> MovieSession:
return MovieSession.objects.get(id=movie_session_id)

Choose a reason for hiding this comment

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

The get_movie_session_by_id function uses MovieSession.objects.get(id=movie_session_id), which will raise a DoesNotExist exception if no MovieSession with the given ID exists. Consider using get_object_or_404 from Django shortcuts if this function is used in a view, or handle the exception appropriately if used elsewhere.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great work on setting up the models and migrations! 🎉 Your implementation is mostly aligned with Django's best practices, and the structure is well-organized. However, there are a few areas to improve:

  1. Exception Handling: The get_movie_by_id and get_movie_session_by_id functions currently lack exception handling for DoesNotExist errors. It's recommended to use get_object_or_404 if these functions are used in views, or handle the exceptions within the functions to ensure robustness.

  2. related_name for cinema_hall: The related_name for the cinema_hall field in the MovieSession model was initially misleading but has been updated to 'movie_sessions', which is now appropriate and descriptive.

Your code is approved to help you move forward with your learning journey. Please review the comments and address the issues to enhance your code quality. Keep up the great work and continue improving! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

name='MovieSession',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('show_time', models.DateTimeField()),

Choose a reason for hiding this comment

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

The cinema_hall field in the MovieSession model is missing a related_name. Consider adding related_name='sessions' to provide a descriptive reverse relation name.

operations = [
migrations.AlterField(
model_name='moviesession',
name='cinema_hall',

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 cinema_hall field is currently set to 'cinema_halls', which is misleading. Consider changing it to 'sessions' to better describe the reverse relationship.

Comment on lines +28 to +29
def get_movie_by_id(movie_id: int) -> Movie:
return Movie.objects.get(id=movie_id)

Choose a reason for hiding this comment

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

The get_movie_by_id function should handle the DoesNotExist exception to avoid potential errors if the movie ID is not found. Consider using get_object_or_404 if this function is used in views, or handle the exception within the function.

Comment on lines +28 to +29
def get_movie_session_by_id(movie_session_id: int) -> MovieSession:
return MovieSession.objects.get(id=movie_session_id)

Choose a reason for hiding this comment

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

The get_movie_session_by_id function should handle the DoesNotExist exception to avoid potential errors if the movie session ID is not found. Consider using get_object_or_404 if this function is used in views, or handle the exception within the function.

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.

3 participants