-
Notifications
You must be signed in to change notification settings - Fork 30
Gormezoglu homework 4 #107
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| def get_queryset(self): | ||
| queryset = super().get_queryset() | ||
| user = self.request.user.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.
login olmamis bir customer varsa sanki problem var.
|
|
||
| class BasketViewSet(DetailedViewSetMixin, viewsets.ModelViewSet): | ||
| permission_classes = () | ||
| http_method_names = ["get", "delete", "post"] |
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.
basketi kullaniciya sildirmek guzel bir fikir degil sanki.
| serializer_action_classes = { | ||
| "detailed_list": BasketDetailedSerializer, | ||
| "detailed": BasketDetailedSerializer, | ||
| "create_product": BasketItemSerializer |
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.
create_product seklinde bir action tanimlamamasiz.
| # customer can only see own basket | ||
| queryset = super().get_queryset() | ||
| user = self.request.user | ||
| return queryset.filter(customer=user) |
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.
login olmamis bir customer varsa sanki problem var.
|
|
||
| @action(detail=True, methods=['post']) | ||
| def add_product(self, request, pk=None): | ||
| serializer = BasketItemSerializer(data=request.data) |
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.
price bilgisini kullanicidan almak guzel gozukmuyor.
| serializer = BasketItemSerializer(data=request.data) | ||
| if serializer.is_valid(): | ||
| serializer.save() | ||
| return Response(serializer.data, status=status.HTTP_201_CREATED) |
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.
basketviewset baskete ait bir serializer verisi donse daha guzel olur.
created register endpoint
modified permisson classes
added an add_product function over baskets