コード例 #1
0
ファイル: views.py プロジェクト: dotKom/feedme
 def create(self, request, *args, **kwargs):
     serializer = self.serializer_class(data=request.data)
     serializer.is_valid(raise_exception=True)
     validate_funds(request.user, float(request.data['price']))
     self.perform_create(serializer)
     headers = self.get_success_headers(serializer.data)
     return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
コード例 #2
0
ファイル: views.py プロジェクト: dotKom/feedme
    def join(self, request, pk=None):
        instance = self.queryset.get(pk=pk)
        validate_funds(request.user, instance.price)
        instance.users.add(request.user)
        instance.save()

        serializer = self.serializer_class(initial=instance)
        headers = self.get_success_headers(serializer.data)
        return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
コード例 #3
0
 def create(self, request, *args, **kwargs):
     serializer = self.serializer_class(data=request.data)
     serializer.is_valid(raise_exception=True)
     validate_funds(request.user, float(request.data['price']))
     self.perform_create(serializer)
     headers = self.get_success_headers(serializer.data)
     return Response(serializer.data,
                     status=status.HTTP_201_CREATED,
                     headers=headers)
コード例 #4
0
    def join(self, request, pk=None):
        instance = self.queryset.get(pk=pk)
        validate_funds(request.user, instance.price)
        instance.users.add(request.user)
        instance.save()

        serializer = self.serializer_class(initial=instance)
        headers = self.get_success_headers(serializer.data)
        return Response(serializer.data,
                        status=status.HTTP_201_CREATED,
                        headers=headers)