def list(request): # Handle file upload if request.method == 'POST': form = DocumentForm(request.POST, request.FILES) if form.is_valid(): newdoc = Document(docfile = request.FILES['docfile']) newdoc.save() # Redirect to the document list after POST return HttpResponseRedirect(reverse('engine.views.list')) else: form = DocumentForm() # A empty, unbound form # Load documents for the list page documents = Document.objects.all() # Render list page with the documents and the form return render_to_response( 'engine/list.html', {'documents': documents, 'form': form}, context_instance=RequestContext(request) )
def display_cluster_engine(request): algorithms, datasets = database_manager.retrieve_interface_data() upload_file_name = "" # Handle file upload if request.method == 'POST': form = DocumentForm(request.POST, request.FILES) if form.is_valid(): # remove whatever is in there now = datetime.datetime.now() if now.month < 10: mth = str(0)+str(now.month) else: mth = str(now.month) if now.day < 10: day = str(0)+str(now.day) else: day = str(now.day) path = '/static_media_clustapp/documents/'+str(now.year)+'/'+mth+'/'+day+'/' full_path = os.path.realpath('.') os.system('rm '+full_path+path+'*') # store uploaded file newdoc = Document(docfile = request.FILES['docfile']) newdoc.save() upload_file_name = request.FILES['docfile'] # debugging use, output the newest file uploaded print 'Newest File Uploaded' os.system('ls '+full_path+path) # Redirect to the document list after POST #return HttpResponseRedirect(reverse('engine.views.display_cluster_engine')) else: form = DocumentForm() # A empty, unbound form # Load documents for the list page documents = Document.objects.all() # Render list page with the documents and the form return render_to_response( 'engine/engine_interface.html', { 'documents': documents, 'form': form, 'algorithms':algorithms, 'datasets': datasets, 'upload':upload_file_name, }, context_instance=RequestContext(request) ) """