Пример #1
0
def analysisAdd(request):
	# check to see if form submitted
	if request.POST:
		form = AnalysisAddForm(request.POST,request.FILES)
		
		# validate form
		if form.is_valid():
		
			if request.FILES:
				handleUploadedFile(request.FILES['file'])
				
			title = form.cleaned_data['title']
			description = form.cleaned_data['description']
			stream = form.cleaned_data['stream']
			file = form.cleaned_data['file']
			author = form.cleaned_data['author']
			
			rep = Analysis(title=title,description=description,stream=stream,file=file,author=author)
			rep.save()
			return HttpResponseRedirect('/analysis/%i',(rep.stream.id))
	else:
		form = AnalysisAddForm() # load unbound form
	
	return render_to_response('market/analysis/add.html', {
		'form':form
		},
		context_instance=RequestContext(request)
Пример #2
0
def analysisDetail(request, stream_id):
	# check to see if form submitted
	if request.POST:
		form = AnalysisAddForm(request.POST,request.FILES)
		
		# validate form
		if form.is_valid():
		
			if request.FILES:
				handleUploadedFile(request.FILES['file'])
			
			stream = form.cleaned_data['stream']
			title = form.cleaned_data['title']
			description = form.cleaned_data['description']
			stream = form.cleaned_data['stream']
			file = form.cleaned_data['file']
			author = form.cleaned_data['author']
			
			analysis = Analysis(title=title,description=description,stream=stream,file=file,author=author)
			analysis.save()
			return HttpResponseRedirect('/analysis/' + stream_id))
	else:
		# load form with stream set
		data = {
			'stream':stream_id
		}