Пример #1
0
    def get(self, request, bid=None):

        if bid is None:
            bid = generator.haikunate()
            batch = Batch.objects.create(uid=bid)
            batch.save()
        else:
            batch = get_batch(bid)

        context = {"batch": batch}

        return render(self.request, 'upload/datasets_upload.html', context)
Пример #2
0
def batch_details(request,bid):
    '''view details for a batch 
    '''
    batch = get_batch(bid)    
    context = {"active":"dashboard",
               "batch" : batch,
               "title": batch.uid }

    # Is the watcher running?
    context['is_watching'] = is_watching()
 
    return render(request, 'batch/batch_details.html', context)
Пример #3
0
def dataset_upload(file_path,bid):
    '''dataset_upload will take an compressed file object, decompress
    it, (again) validate it for correctness, and then upload the dataset.
    '''
    from dicomdb.apps.main.utils import get_batch, upload_dicom_batch
    batch = get_batch(bid)
    tmpdir = os.path.dirname(file_path)
  
    # Add image and headers to batch
    image = upload_dicom_batch(batch=batch,
                               dicom_file=file_path)

    shutil.rmtree(tmpdir)
Пример #4
0
    def post(self, request, bid):

        batch = get_batch(bid)

        # A post without files, not sure how/why this would be done, but should be caught
        if request.FILES == None:
            data = {'is_valid': False, 'name': "No files provided", 'url': "/"}
            return JsonResponse(data)

        # Generate a new batch
        data = batch_memory_upload(memory_file=request.FILES['file'],
                                   batch=batch)

        if data['is_valid'] == True:
            messages.info(
                request,
                "Your datasets are uploading. Please refresh the page if you do not see them."
            )

        return JsonResponse(data)
Пример #5
0
def get_batch_context(bid):
    '''a repeated sequence of calls to get the context
    for a batch based on id'''
    batch = get_batch(bid)
    context = {"active": "dashboard", "batch": batch, "title": batch.uid}
    return context