Пример #1
0
 def put(self, request, registration_id, format=None):
     gcmDevice = self.get_object(registration_id)
     serializer = GCMDeviceSerializer(gcmDevice, 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 post(self, request, format=None):
     serializer = GCMDeviceSerializer(data=request.data)
     if serializer.is_valid():
         # Ensure the registration_id is only in the GCMDevice table once
         if GCMDevice.objects.filter(registration_id = request.data['registration_id']) is not None:
             GCMDevice.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)
Пример #3
0
 def get(self, request, registration_id, format=None):
     gcmDevice = self.get_object(registration_id)
     serializer = GCMDeviceSerializer(gcmDevice)
     return Response(serializer.data)
Пример #4
0
 def get(self, request, format=None):
     #gcmDevices = list(GCMDevice.objects.filter(user=request.user))
     gcmDevices = list(GCMDevice.objects.all())
     serializer = GCMDeviceSerializer(gcmDevices, many=True)
     return Response(serializer.data)