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

Develop #744

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

Develop #744

wants to merge 9 commits into from

Conversation

job-artem
Copy link

ready solution!

…ers that filtered by the authenticated user. Add detail information about movie session
…t forget to place config in the settings.py.
…filtered by the authenticated user. Add detail information about movie session and implement pagination. Note, to implement pagination don't forget to place config in the settings.py.
…ated user. It should support the following request structure:
…=, ?genres= and ?title= parameters. Filtering by title with the string parameter should return all movies whose title contains string.
…ould be provided in year-month-day format, the movie by its id.
…ys about how many tickets are still available for each movie_session
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 implementing the API endpoints and ensuring robust functionality! 🎉 While there are a few minor issues, such as pagination not being applied to the OrdersViewSet and some code style improvements, these do not critically impact the functionality. Consider addressing these in future iterations for enhanced code quality. Keep up the excellent work! 🚀

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

model_name='movie',
name='duration',
model_name="movie",
name="duration",
field=models.IntegerField(default=123),

Choose a reason for hiding this comment

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

The default value is set to 123, but preserve_default is set to False. This means that the default value will not be preserved for existing rows in the database. If you intend to apply this default value to existing records, consider setting preserve_default to True or handling existing records separately.

model_name='genre',
name='name',
model_name="genre",
name="name",
field=models.CharField(max_length=255, unique=True),

Choose a reason for hiding this comment

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

Setting the name field to unique=True means that all existing and future entries must have unique values for this field. Ensure that there are no duplicate name values in the existing database records, as this will cause the migration to fail.

f"{str(self.movie_session)} (row: {self.row}, seat: {self.seat})"
)
return (f"{str(self.movie_session)}"
f" (row: {self.row}, seat: {self.seat})")

class Meta:
unique_together = ("movie_session", "row", "seat")

Choose a reason for hiding this comment

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

The unique_together constraint ensures that each combination of movie_session, row, and seat is unique. This is important for preventing duplicate tickets for the same seat in a session. Ensure that this constraint is properly enforced in your database schema.



class OrderSerializer(serializers.ModelSerializer):
tickets = TicketSerializer(many=True, allow_empty=False)

Choose a reason for hiding this comment

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

The allow_empty=False parameter in the tickets field ensures that an order cannot be created without tickets. This is a good validation step to prevent empty orders.

tickets_data = validated_data.pop("tickets")
user = self.context["request"].user

with transaction.atomic():

Choose a reason for hiding this comment

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

Using transaction.atomic() ensures that the order and all associated tickets are created as a single transaction, which helps maintain data integrity in case of errors during the creation process.

queryset = queryset.filter(actors__id__in=actor_ids)

# Remove duplicates caused by many-to-many relationships
return queryset.distinct()

Choose a reason for hiding this comment

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

The distinct() method is used to remove duplicates caused by many-to-many relationships, ensuring that the queryset returns unique results.

queryset = Order.objects.all()

def get_queryset(self):
return Order.objects.filter(user=self.request.user)

Choose a reason for hiding this comment

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

The get_queryset method restricts the orders to those belonging to the authenticated user, ensuring that users can only access their own orders.


#
def perform_create(self, serializer):
serializer.save(user=self.request.user)

Choose a reason for hiding this comment

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

The perform_create method ensures that the order is saved with the current authenticated user, maintaining data integrity and security.

"django-insecure-6vubhk2$++agnctay_4pxy_8cq)mosmn(*-#2b^v4cgsh-^!i3"
)
SECRET_KEY = ("django-insecure-6vubhk2$++agnctay_4pxy_8cq)"
"mosmn(*-#2b^v4cgsh-^!i3")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

Choose a reason for hiding this comment

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

The DEBUG setting is set to True, which is suitable for development but should be set to False in production to avoid exposing sensitive information.

Comment on lines +23 to +24
SECRET_KEY = ("django-insecure-6vubhk2$++agnctay_4pxy_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 should be kept secret in production environments. Consider using environment variables or a secrets manager to handle this securely.

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