def submit_string(request): if request.method == 'POST': form = TextForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('CatchShow.submit.views.submitSuccess')) else: form = TextForm() return render_to_response('submitString.html', {'form': form}, context_instance=RequestContext(request) )
def submit_file_to_string(request): if request.method == 'POST': form = UploadFileForm(request.POST, request.FILES) if form.is_valid(): uploadfile = request.FILES['upfile'] if uploadfile is None: return render_to_response('test.html', context_instance=RequestContext(request) ) content = uploadfile.read() ucontent = unicode(content) curtime = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time())) textform = TextForm({'id':curtime,'string_text':ucontent}) if textform.is_valid(): textform.save() return HttpResponseRedirect(reverse('CatchShow.submit.views.submitSuccess')) else: form = UploadFileForm() return render_to_response('submitFile.html', {'form': form}, context_instance=RequestContext(request) )