예제 #1
0
def process(request):
    if request.method == 'POST':
        form = UploadedFileForm(request.POST, request.FILES)
        if form.is_valid():
            motive = form.cleaned_data["motive"]
            instances_used = form.cleaned_data["instance_num"]
            seed_content = request.FILES['file'].read()


            fetcher = Fetcher("fetch_queue", instances_used)
            instances_ids = fetcher.fetch(seed_content)

            #Could not parse directly from form because of the file
            req_model = Request()
            req_model.motive = motive
            req_model.instances_used = instances_used
            req_model.user = request.user
            req_model.content = seed_content
            req_model.instances_ids = json.dumps(instances_ids)
            req_model.save()

            return HttpResponseRedirect("/process/%d" % req_model.id)