Пример #1
0
 def put(self, request, file_id):
 	print 'inside PUT method'
     serializer = FileSerializer(data=request.DATA)
     if not serializer.is_valid():
         return Response(serializer.errors, status=
             status.HTTP_400_BAD_REQUEST)
     else:
         data = serializer.data
         t = InputFile(id=inputfile_id, input_user=request.user, audio_file=request.FILES,\
                  rec_date=datetime.now())
         t.save()
         return Response(status=status.HTTP_200_OK)
Пример #2
0
 def put(self, request, file_id):
     print 'inside PUT method'
     serializer = FileSerializer(data=request.DATA)
     if not serializer.is_valid():
         return Response(serializer.errors,
                         status=status.HTTP_400_BAD_REQUEST)
     else:
         data = serializer.data
         t = InputFile(id=inputfile_id, input_user=request.user, audio_file=request.FILES,\
                  rec_date=datetime.now())
         t.save()
         return Response(status=status.HTTP_200_OK)
Пример #3
0
 def post(self, request, filename, format=None):
     print 'post method in FileView'
     
     serializer = FileSerializer(data=request.DATA)
     print request.FILES
     if not serializer.is_valid():
         return Response(serializer.errors, status=
             status.HTTP_400_BAD_REQUEST)
     else:
         data = serializer.data
         input_user = request.user
         t = File(input_user=input_user, audio_file=request.FILES)
         t.save()
         request.DATA['id'] = t.pk # return id
         return Response(request.DATA, status=status.HTTP_201_CREATED)
Пример #4
0
    def post(self, request, filename, format=None):
        print 'post method in FileView'

        serializer = FileSerializer(data=request.DATA)
        print request.FILES
        if not serializer.is_valid():
            return Response(serializer.errors,
                            status=status.HTTP_400_BAD_REQUEST)
        else:
            data = serializer.data
            input_user = request.user
            t = File(input_user=input_user, audio_file=request.FILES)
            t.save()
            request.DATA['id'] = t.pk  # return id
            return Response(request.DATA, status=status.HTTP_201_CREATED)
Пример #5
0
 def get(self, request):
     print 'get method in FileView'
     print request.FILES
     queryset = InputFile.objects.all()
     files = InputFile.objects.filter(input_user=request.user.id)
     serializer = FileSerializer(files,
                                 many=True,
                                 context={'request': request})
     return Response(serializer.data)