Exemplo n.º 1
0
def new(request):
	contextVariables = {'submitName':'Create', 'submitAction':"/WaitLanes/new/", 'formType': 'new'}
	if request.method == 'GET':
		f = WaitLaneForm()	
		contextVariables['WaitLaneForm'] = f
	elif request.method == 'POST':
		f = WaitLaneForm(request.POST, request.FILES)
		contextVariables['WaitLaneForm'] = f
		if f.is_valid():
			waitLane = f.save()
			return redirect("/WaitLanes/edit/"+str(waitLane.id)+"/")
	return render(request, 'WaitLaneForm.html', dictionary=contextVariables)
Exemplo n.º 2
0
def edit(request, waitLaneStrId):
	#pdb.set_trace()		
	waitLaneId = int(waitLaneStrId)	
	contextVariables = {'submitName':'save', 'submitAction':"/WaitLanes/edit/"+waitLaneStrId+"/", 'formType': 'edit'}
	try:
		waitLane = instance=WaitLane.objects.get(id=waitLaneId)
		contextVariables['WaitLane'] = waitLane
		if request.method == 'GET':
			f = WaitLaneForm(instance=waitLane)
			contextVariables['WaitLaneForm'] = f
			return render(request, 'WaitLaneForm.html', dictionary=contextVariables)
		elif request.method == 'POST':
			f = WaitLaneForm(request.POST, request.FILES, instance=waitLane)
			contextVariables['WaitLaneForm'] = f
			if f.is_valid():
				waitLane = f.save()
				return redirect("/WaitLanes/edit/"+str(waitLane.id)+"/")
			return render(request, 'WaitLaneForm.html', dictionary=contextVariables)
	except ObjectDoesNotExist:
		return render(request, 'WaitLaneDoesNotExist.html', dictionary={'id': waitLaneId})