예제 #1
0
파일: views.py 프로젝트: bigbang4u2/mywork
def ResourceBidRegister(request):
	errors = [] 
	form = ResourceBidDetailsForm()
	#display all registered machines of user
	machines = displayProviderMachines(request)
	p_ID = getProviderID(request)['providerID']
	resource = Resource.objects.filter(providerID = p_ID)
	#print a
	if not getProviderID(request)['bool']:
		errors.append('First Register for Provider')
	elif request.method == 'POST':
		form = ResourceBidDetailsForm(request.POST)
		if form.is_valid():
			r_ID = request.POST['resourceID']
			r_ID = Resource.objects.get(resourceID = r_ID)
			sdt = form.cleaned_data['startDateTime']
			edt = form.cleaned_data['endDateTime']
			sp = form.cleaned_data['startPrice']
			if getMachineID(r_ID)['bool']:
				machineID = getMachineID(r_ID)['machineID']
				machineID.startDateTime = sdt
				machineID.endDateTime = edt
				machineID.startPrice = sp
				machineID.save()
			else:	
				insert = ResourceBidDetails(resourceID = r_ID,providerID = p_ID, startDateTime = sdt, endDateTime = edt, startPrice = sp)
				insert.save()
			resourceObj = Resource.objects.get(resourceID = r_ID)
			resourceObj.availability = 'A'
			resourceObj.save()
			return HttpResponseRedirect('/')
	else:
		form = ResourceBidDetailsForm()
	return render_to_response("bidding/bidding_details.html",{'form':form, 'errors':errors,'resource': resource,'machines' : machines},context_instance = RequestContext(request))
예제 #2
0
파일: views.py 프로젝트: bigbang4u2/mywork
def displayProviderMachines(request):
	try:
		machines = []
		p_ID = getProviderID(request)['providerID']
		machines = ResourceBidDetails.objects.filter(providerID = p_ID)
		return machines
	except ResourceBidDetails.DoesNotExist:
		return False
예제 #3
0
파일: views.py 프로젝트: bigbang4u2/mywork
def ResourceRegister(request):
	errors = []
	form = ResourceForm()
	if not getProviderID(request)['bool']:
		errors.append('First Register for Provider')
	elif request.method == 'POST':
		form = ResourceForm(request.POST)
		if form.is_valid():
			
				r_ID = form.cleaned_data['resourceID']
				p_ID = getProviderID(request)['providerID']
				avail = form.cleaned_data['availability']
				insert = Resource(resourceID = r_ID, providerID = p_ID, availability = avail)
				insert.save()
				return HttpResponseRedirect('/')
	else:
		form = ResourceForm()
	return render_to_response("resources/resource_register.html",{'form':form, 'errors':errors},context_instance = RequestContext(request))