Exemplo n.º 1
0
    def save_sound_package(self):

        info_package = self.sound_package[SP_Key]
        artist = self.sound_package[A_Key]

        data = {ALB_Key: info_package[ALB_Key],
                T_Key: info_package[T_Key],
                A_Key: artist[U_Key],
                STR_Key: info_package[STR_Key],
                }

        # save sound package to the correct queue item
        queue_items = QueueItem.objects.filter(sound_url=self.sound_url)
        for queue_item in queue_items:
            queue_item_serialized = QueueItemSerializer(queue_item, data=data, partial=True)
            print(queue_item_serialized.is_valid())
            if queue_item_serialized.is_valid():
                queue_item_serialized.save()
Exemplo n.º 2
0
def receive_added_sound(request):
    if request.method == 'POST':
        queue_item = QueueItemSerializer(data=request.data)
        if queue_item.is_valid():

            queue_item.save()

            queue_id = queue_item.validated_data[Q_Key]
            sound_url = queue_item.validated_data[S_Key]

            # send queue to specific phone
            firebase_connect.send_added_sound(queue_id, sound_url)
            # respond with an OK
            return Response(request.data, status=status.HTTP_200_OK)
    return Response(request.data, status=status.HTTP_200_OK)