Пример #1
0
 def put(self, request, registration_id, format=None):
     apnsDevice = self.get_object(registration_id)
     serializer = APNSDeviceSerializer(apnsDevice, data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Пример #2
0
 def put(self, request, registration_id, format=None):
     apnsDevice = self.get_object(registration_id)
     serializer = APNSDeviceSerializer(apnsDevice, data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Пример #3
0
 def post(self, request, format=None):
     serializer = APNSDeviceSerializer(data=request.data)
     if serializer.is_valid():
         # Ensure the registration_id is only in the APNSDevice table once
         if APNSDevice.objects.filter(registration_id = request.data['registration_id']) is not None:
             APNSDevice.objects.filter(registration_id = request.data['registration_id']).delete()
         serializer.save(user=self.request.user)
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Пример #4
0
 def post(self, request, format=None):
     serializer = APNSDeviceSerializer(data=request.data)
     if serializer.is_valid():
         # Ensure the registration_id is only in the APNSDevice table once
         if APNSDevice.objects.filter(registration_id = request.data['registration_id']) is not None:
             APNSDevice.objects.filter(registration_id = request.data['registration_id']).delete()
         serializer.save(user=self.request.user)
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Пример #5
0
 def get(self, request, registration_id, format=None):
     apnsDevice = self.get_object(registration_id)
     serializer = APNSDeviceSerializer(apnsDevice)
     return Response(serializer.data)
Пример #6
0
 def get(self, request, format=None):
     #gcmDevices = list(GCMDevice.objects.filter(user=request.user))
     apnsDevices = list(APNSDevice.objects.all())
     serializer = APNSDeviceSerializer(apnsDevices, many=True)
     return Response(serializer.data)