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

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

solution #700

wants to merge 9 commits into from

Conversation

serhiik05
Copy link

No description provided.

Copy link

@94nj111 94nj111 left a comment

Choose a reason for hiding this comment

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

GJ!

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! 😊 While you've done a great job overall, there are a few critical issues that need to be addressed before we can approve the pull request:

  1. Syntax Error in Ticket Class: There's a syntax error in the __str__ method due to an incorrect line continuation character. This needs to be fixed to ensure the code runs correctly.

  2. validate_ticket Method: The call to validate_ticket is missing the error_to_raise parameter. This is required according to the method definition, so please ensure it's included.

  3. Security Concern in settings.py: The SECRET_KEY is hardcoded, which is a security risk. Consider using environment variables to manage sensitive information securely.

  4. Test Cases for API Methods: The test_put_movie and test_delete_movie methods expect a 405 Method Not Allowed response. Please verify that the API is configured correctly to disallow these requests if that's the intended behavior, or adjust the tests accordingly.

Once these issues are resolved, your code will be in great shape! Keep up the fantastic work, and don't hesitate to reach out if you need any help. 🌟

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

cinema/models.py Outdated
Comment on lines 123 to 124
return f"{str(self.movie_session)} "\
f"(row: {self.row}, seat: {self.seat})"

Choose a reason for hiding this comment

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

There is a syntax error in the __str__ method of the Ticket class. The line continuation character \ should be placed at the end of line 123, not at the beginning of line 124. This will fix the syntax error.

Copy link
Contributor

Choose a reason for hiding this comment

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

😭 whyyyy

Comment on lines +89 to +90
Ticket.validate_ticket(attrs["row"], attrs["seat"],
attrs["movie_session"])

Choose a reason for hiding this comment

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

The validate_ticket method call is missing the error_to_raise parameter. According to the validate_ticket method definition in the Ticket model, this parameter is required. You should pass ValidationError as the fourth argument to match the method signature.

self.assertEqual(
response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED
)
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)

Choose a reason for hiding this comment

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

The test_put_movie method expects a 405 Method Not Allowed response. Ensure that the API is configured to disallow PUT requests on the movie detail endpoint if this is the expected behavior. Otherwise, adjust the test to match the actual API behavior.

self.assertEqual(
response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED
)
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)

Choose a reason for hiding this comment

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

The test_delete_movie method expects a 405 Method Not Allowed response. Verify that the API is set up to disallow DELETE requests on the movie detail endpoint. If DELETE requests are allowed, update the test to reflect the correct expected status code.

Copy link
Contributor

Choose a reason for hiding this comment

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

agree, usually delete methor returns 302 status

Comment on lines +24 to +25
"django-insecure-6vubhk2$++agnctay_4"
"pxy_8cq)mosmn(*-#2b^v4cgsh-^!i3"

Choose a reason for hiding this comment

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

The SECRET_KEY is hardcoded and visible in the settings file. For security reasons, it's important to keep this key secret in production. Consider using environment variables or a separate configuration file to manage sensitive information.

Comment on lines 17 to 20
read_only = (
"id",
"is_staff",
)

Choose a reason for hiding this comment

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

The read_only attribute in the Meta class should be read_only_fields. This is the correct attribute name for specifying fields that should be read-only in Django REST Framework serializers.

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 job on your submission! 🎉 You've made significant progress in addressing the issues identified in your code. Here are some key points to focus on:

  1. Syntax Error in Ticket Class: Ensure that the syntax error in the __str__ method is corrected by placing the line continuation character \ at the end of the appropriate line. This will ensure your code runs smoothly.

  2. validate_ticket Method: Make sure to include the error_to_raise parameter in the validate_ticket method call. This is crucial for handling validation errors correctly in your TicketSerializer.

  3. Security Concern in settings.py: The hardcoded SECRET_KEY is a security risk. It's important to use environment variables to manage sensitive information securely, especially in production environments.

  4. Test Cases for API Methods: Verify that the test_put_movie and test_delete_movie methods align with the intended API behavior. If the API is configured to disallow PUT and DELETE requests, ensure the tests reflect this. Otherwise, adjust the tests accordingly.

Your effort in addressing these issues is commendable. Keep up the good work, and remember to review the comments to further improve your code. Addressing these points will enhance the security and functionality of your application. Keep learning and growing! 🚀

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

cinema/models.py Outdated
Comment on lines 123 to 124
return f"{str(self.movie_session)} "\
f"(row: {self.row}, seat: {self.seat})"

Choose a reason for hiding this comment

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

There is a syntax error in the __str__ method of the Ticket class. The line continuation character \ should be placed at the end of line 123, not at the beginning of line 124. This will fix the syntax error.

Comment on lines +89 to +90
Ticket.validate_ticket(attrs["row"], attrs["seat"],
attrs["movie_session"])

Choose a reason for hiding this comment

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

The validate_ticket method call is missing the error_to_raise parameter. According to the method definition in the Ticket model, this parameter is required. Please ensure to pass the appropriate exception class, such as serializers.ValidationError, to handle validation errors correctly.

self.assertEqual(
response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED
)
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)

Choose a reason for hiding this comment

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

The test_put_movie method expects a 405 Method Not Allowed response. Please verify that the API is configured to disallow PUT requests on the movie endpoint if this is the intended behavior. Otherwise, adjust the test to match the actual API behavior.

self.assertEqual(
response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED
)
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)

Choose a reason for hiding this comment

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

The test_delete_movie method expects a 405 Method Not Allowed response. Please verify that the API is configured to disallow DELETE requests on the movie endpoint if this is the intended behavior. Otherwise, adjust the test to match the actual API behavior.

Comment on lines +24 to +25
"django-insecure-6vubhk2$++agnctay_4"
"pxy_8cq)mosmn(*-#2b^v4cgsh-^!i3"

Choose a reason for hiding this comment

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

The SECRET_KEY is hardcoded, which poses a security risk. Consider using environment variables to manage sensitive information securely, especially for production environments. This aligns with best practices for Django projects.

Copy link
Contributor

@Nattalli Nattalli left a comment

Choose a reason for hiding this comment

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

I just 😭 💀

cinema/models.py Outdated
Comment on lines 66 to 67
user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE)
Copy link
Contributor

Choose a reason for hiding this comment

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

why?

cinema/models.py Outdated
Comment on lines 123 to 124
return f"{str(self.movie_session)} "\
f"(row: {self.row}, seat: {self.seat})"
Copy link
Contributor

Choose a reason for hiding this comment

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

😭 whyyyy

Comment on lines 40 to 42
genres = serializers.SlugRelatedField(many=True,
read_only=True,
slug_field="name")
Copy link
Contributor

Choose a reason for hiding this comment

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

💀

self.assertEqual(
response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED
)
self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
Copy link
Contributor

Choose a reason for hiding this comment

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

agree, usually delete methor returns 302 status

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.

4 participants