Esempio n. 1
0
    def post(self, request):
        metadata = json.loads(request.POST.get('meta'))
        print metadata
        meta_uid = metadata['meta_uid']
        print meta_uid
        token = request.POST.get('token')
        print token
        upload_id = request.POST.get('upload_id')
        print upload_id
        try:
            decoded = jwt.decode(token, SECRET_KEY)
        except:
            return Response('Authentication expired', status=404)

        user = User.objects.get(id=decoded['user_id'])
        print 'Vamos a probar...'
        meta = Metadata.objects.filter(uid=meta_uid)
        if len(meta) == 0:
            print 'PRIMERA VEZ!!!'
            meta = Metadata(
                user=user,
                uid=meta_uid,
                sequencing_platform=metadata['sequencing_platform'],
                sequencing_type=metadata['sequencing_type'],
                pre_assembled=metadata['pre_assembled'],
                isolation_source=metadata['isolation_source'],
                pathogenic=metadata['pathogenic'],
                sample_name=metadata['sample_name'],
                longitude=metadata['longitude'],
                latitude=metadata['latitude'],
                organism=metadata['organism'],
                strain=metadata['strain'],
                subtype=metadata['subtype'],
                country=metadata['country'],
                region=metadata['region'],
                city=metadata['city'],
                zip_code=metadata['zip_code'],
                location_note=metadata['location_note'],
                source_note=metadata['source_note'],
                pathogenicity_note=metadata['pathogenicity_note'],
                collected_by=metadata['collected_by'],
                email_address=metadata['email_address'],
                notes=metadata['notes'],
                collection_date=metadata['collection_date'],
                release_date=metadata['release_date'])
            meta.save()
        else:
            print 'YA EXISTIAAAAA'
            meta = meta[0]
            print meta
        print meta_uid
        files = MyChunkedUpload.objects.filter(meta_uid=meta_uid)
        print files
        for file in files:
            print meta
            file.meta_id = meta
            file.save()
        return Response('Everything went accordint to plan...', status=200)
Esempio n. 2
0
    def post(self, request):
        metadata = json.loads(request.POST.get('meta'))
        print metadata
        meta_uid = metadata['meta_uid']
        print meta_uid
        token = request.POST.get('token')
        print token
        upload_id = request.POST.get('upload_id')
        print upload_id
        try:
            decoded = jwt.decode(token, SECRET_KEY)
        except:
            return Response('Authentication expired', status=404)

        user = User.objects.get(id=decoded['user_id'])
        print 'Vamos a probar...'
        meta = Metadata.objects.filter(uid=meta_uid)
        if len(meta) == 0:
            print 'PRIMERA VEZ!!!'
            meta = Metadata(
                user=user,
                uid=meta_uid,
                sequencing_platform=metadata['sequencing_platform'],
                sequencing_type=metadata['sequencing_type'],
                pre_assembled=metadata['pre_assembled'],
                isolation_source=metadata['isolation_source'],
                pathogenic=metadata['pathogenic'],
                sample_name=metadata['sample_name'],
                longitude=metadata['longitude'],
                latitude=metadata['latitude'],
                organism=metadata['organism'],
                strain=metadata['strain'],
                subtype=metadata['subtype'],
                country=metadata['country'],
                region=metadata['region'],
                city=metadata['city'],
                zip_code=metadata['zip_code'],
                location_note=metadata['location_note'],
                source_note=metadata['source_note'],
                pathogenicity_note=metadata['pathogenicity_note'],
                collected_by=metadata['collected_by'],
                email_address=metadata['email_address'],
                notes=metadata['notes'],
                collection_date=metadata['collection_date'],
                release_date=metadata['release_date'])
            meta.save()
        else:
            print 'YA EXISTIAAAAA'
            meta = meta[0]
            print meta
        print meta_uid
        files = MyChunkedUpload.objects.filter(meta_uid=meta_uid)
        print files
        for file in files:
            print meta
            file.meta_id = meta
            file.save()
        return Response('Everything went accordint to plan...', status=200)
Esempio n. 3
0
    def on_completion(self, uploaded_file, request):
        # Do something with the uploaded file. E.g.:
        # * Store the uploaded file on another model:
        # SomeModel.objects.create(user=request.user, file=uploaded_file)
        # * Pass it as an argument to a function:
        # function_that_process_file(uploaded_file)
        upload_id = request.POST.get('upload_id')
        metadata = json.loads(request.POST.get('meta'))
        meta_uid = metadata['meta_uid']
        chunked_upload = get_object_or_404(self.get_queryset(request),
                                           upload_id=upload_id)
        chunked_upload.meta_uid = meta_uid
        chunked_upload.save()

        #  Save Metadata
        metadata = json.loads(request.POST.get('meta'))
        meta_uid = metadata['meta_uid']
        token = request.POST.get('token')
        upload_id = request.POST.get('upload_id')
        try:
            decoded = jwt.decode(token, SECRET_KEY)
        except:
            return Response('Authentication expired', status=404)

        user = User.objects.get(id=decoded['user_id'])
        print 'Vamos a probar...'
        meta = Metadata.objects.filter(uid=meta_uid)
        if len(meta) == 0:
            print 'There is no record of metatada in DB'
            meta = Metadata(
                user=user,
                uid=meta_uid,
                sequencing_platform=metadata['sequencing_platform'],
                sequencing_type=metadata['sequencing_type'],
                pre_assembled=metadata['pre_assembled'],
                isolation_source=metadata['isolation_source'],
                pathogenic=metadata['pathogenic'],
                sample_name=metadata['sample_name'],
                longitude=metadata['longitude'],
                latitude=metadata['latitude'],
                organism=metadata['organism'],
                strain=metadata['strain'],
                subtype=metadata['subtype'],
                country=metadata['country'],
                region=metadata['region'],
                city=metadata['city'],
                zip_code=metadata['zip_code'],
                location_note=metadata['location_note'],
                source_note=metadata['source_note'],
                pathogenicity_note=metadata['pathogenicity_note'],
                collected_by=metadata['collected_by'],
                email_address=metadata['email_address'],
                notes=metadata['notes'],
                collection_date=metadata['collection_date'],
                release_date=metadata['release_date'])
            try:
                meta.save()
            except:
                print 'There seems to be a race condition here................'
                meta = Metadata.objects.filter(uid=meta_uid)
                meta = meta[0]
        else:
            print 'Uploading the second file...'
            meta = meta[0]
        files = MyChunkedUpload.objects.filter(meta_uid=meta_uid)
        for file in files:
            file.meta_id = meta
            file.save()
Esempio n. 4
0
    def on_completion(self, uploaded_file, request):
        # Do something with the uploaded file. E.g.:
        # * Store the uploaded file on another model:
        # SomeModel.objects.create(user=request.user, file=uploaded_file)
        # * Pass it as an argument to a function:
        # function_that_process_file(uploaded_file)
        upload_id = request.POST.get('upload_id')
        metadata = json.loads(request.POST.get('meta'))
        meta_uid = metadata['meta_uid']
        chunked_upload = get_object_or_404(self.get_queryset(request),
                                           upload_id=upload_id)
        chunked_upload.meta_uid = meta_uid
        chunked_upload.save()
        #  Save Metadata
        metadata = json.loads(request.POST.get('meta'))
        print metadata
        meta_uid = metadata['meta_uid']
        print meta_uid
        token = request.POST.get('token')
        print token
        upload_id = request.POST.get('upload_id')
        print upload_id
        try:
            decoded = jwt.decode(token, SECRET_KEY)
        except:
            return Response('Authentication expired', status=404)

        user = User.objects.get(id=decoded['user_id'])
        print 'Vamos a probar...'
        meta = Metadata.objects.filter(uid=meta_uid)
        if len(meta) == 0:
            print 'PRIMERA VEZ!!!'
            meta = Metadata(
                user=user,
                uid=meta_uid,
                sequencing_platform=metadata['sequencing_platform'],
                sequencing_type=metadata['sequencing_type'],
                pre_assembled=metadata['pre_assembled'],
                isolation_source=metadata['isolation_source'],
                pathogenic=metadata['pathogenic'],
                sample_name=metadata['sample_name'],
                longitude=metadata['longitude'],
                latitude=metadata['latitude'],
                organism=metadata['organism'],
                strain=metadata['strain'],
                subtype=metadata['subtype'],
                country=metadata['country'],
                region=metadata['region'],
                city=metadata['city'],
                zip_code=metadata['zip_code'],
                location_note=metadata['location_note'],
                source_note=metadata['source_note'],
                pathogenicity_note=metadata['pathogenicity_note'],
                collected_by=metadata['collected_by'],
                email_address=metadata['email_address'],
                notes=metadata['notes'],
                collection_date=metadata['collection_date'],
                release_date=metadata['release_date'])
            try:
              meta.save()
            except:
              print 'Pues ha dado error...'
              meta = Metadata.objects.filter(uid=meta_uid)
              meta = meta[0]
        else:
            print 'YA EXISTIAAAAA'
            meta = meta[0]
            print meta
        print meta_uid
        files = MyChunkedUpload.objects.filter(meta_uid=meta_uid)
        print files
        for file in files:
            print meta
            file.meta_id = meta
            file.save()