Пример #1
0
def upload_file(request):
    files = Document.objects.all()
    if request.method == 'POST':
        form = DocumentForm(request.POST, request.FILES)
	if form.is_valid():
	    messages.success(request, '上传成功')
	    file = request.FILES.getlist('docfile')
	    for fi in file:
	    	f = Document(docfile = fi)
		f.save()
	    return HttpResponseRedirect('/Iwork/admin/file_upload/')
	else:
	    return render_to_response('admin_file_up.html',RequestContext(request, locals()))
    else:
        form = DocumentForm()
    return render_to_response('admin_file_up.html',RequestContext(request, locals()))
Пример #2
0
def service_add(request):
    serverlist = System_servermanager.objects.all()	
    if request.method == 'POST':
	form = ServeraddForm(request.POST)
        fileform = DocumentForm(request.POST, request.FILES)
	if form.is_valid() and fileform.is_valid():
	    cd = form.cleaned_data
	    servername = request.POST.get('servername')
	    servername = cd['servername'].strip()   
	    scriptname = request.POST.get('scriptname')
	    scriptname = cd['scriptname'].strip()
	    server_manager_list = System_servermanager(servername=servername,scriptname=scriptname)
	    server_manager_list.save()

	    f = Document(docfile = request.FILES['docfile'])
	    f.save()		
            return HttpResponseRedirect('/Iwork/admin/service_manager/')
    else:
	form = ServeraddForm()
	fileform = DocumentForm()
    return render_to_response('admin_service_add.html',locals(),context_instance=RequestContext(request))