Example #1
0
 def create(self, request, *args, **kwargs):
     id_token = request.query_params.get('id_token')
     req_data = request.data.copy()
     req_data["username"] = get_uid(id_token)
     serializer = self.get_serializer(data=req_data)
     serializer.is_valid(raise_exception=True)
     self.perform_create(serializer)
     headers = self.get_success_headers(serializer.data)
     return Response(serializer.data,
                     status=status.HTTP_201_CREATED,
                     headers=headers)
Example #2
0
 def list(self, request):
     id_token = request.query_params.get('id_token')
     uid = get_uid(id_token)
     if uid != None:
         try:
             qset = Address.objects.filter(user_name=uid)
             serializer = AddressSerializer(qset, many=True)
             return Response(serializer.data)
         except:
             serializer = AddressSerializer(self.queryset, many=True)
             return Response(serializer.data)
     serializer = AddressSerializer(self.queryset, many=True)
     return Response(serializer.data)
Example #3
0
 def list(self, request):
     id_token = request.query_params.get('id_token')
     uid = get_uid(id_token)
     if uid != None:
         try:
             user = User.objects.get(username=uid)
             qset = Payment.objects.filter(user=user)
             serializer = PaymentSerializer(qset, many=True)
             return Response(serializer.data)
         except:
             serializer = PaymentSerializer(self.queryset, many=True)
             return Response(serializer.data)
     serializer = PaymentSerializer(self.queryset, many=True)
     return Response(serializer.data)