コード例 #1
0
ファイル: views.py プロジェクト: CicloviaTeam/CicloviaProgram
def upload(request):
	if request.method == 'POST':
		form = UploadForm(request.POST, request.FILES)
		if form.is_valid():
			newdoc = Document(filename = request.POST['filename'],
							  docfile = request.FILES['docfile'])
			newdoc.save(form)
			name = settings.MEDIA_ROOT + str(newdoc.docfile)
			CicloviaScript.buildCiclovia(name, request.user)
		return HttpResponseRedirect(reverse('CicloviaProgram:userModels'))

	else:
		form = UploadForm()
	return render(request, 'ciclovia/upload.html', {'form': form})
コード例 #2
0
ファイル: views.py プロジェクト: CicloviaTeam/CicloviaProgram
def uploadArrivalInfo(request, ciclovia_id):
	ciclovia = get_object_or_404(Ciclovia, pk=ciclovia_id)
	if not (ciclovia.user == request.user or request.user.is_superuser):
		raise PermissionDenied
	if request.method == 'POST':
		form = UploadForm(request.POST, request.FILES)
		if form.is_valid():
			newdoc = Document(filename = request.POST['filename']
							  ,docfile = request.FILES['docfile'])
			newdoc.save(form)
			name = settings.MEDIA_ROOT + str(newdoc.docfile)
			cicloviaToLoad = CicloviaScript.loadCiclovia(ciclovia_id)
			CicloviaScript.assignArrivalInfo(cicloviaToLoad, ciclovia_id, name)
			cicloviaLoad = get_object_or_404(Ciclovia, pk=ciclovia_id)
			return render(request, 'ciclovia/detailArrival.html',
							  {'ciclovia': cicloviaLoad})
		else:
			return render(request, 'ciclovia/upload.html', {'form': form})
	else:
		form = UploadForm()
	return render(request, 'ciclovia/upload.html', {'form': form})