Skip to content
This repository was archived by the owner on May 12, 2023. It is now read-only.

Conversation

@Gormezoglu
Copy link

created register endpoint
modified permisson classes
added an add_product function over baskets


def get_queryset(self):
queryset = super().get_queryset()
user = self.request.user.id
Copy link
Owner

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"]
Copy link
Owner

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
Copy link
Owner

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)
Copy link
Owner

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)
Copy link
Owner

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)
Copy link
Owner

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants