Exemple #1
0
def MainPage(request):
	#contacts = Contact.objects.all().order_by("-id")[:10]
	contacts = []
	cursor = connection.cursor()
	cursor.callproc('OnlineDating_Contact_User_Get')
	raw_Contacts = cursor.fetchall()
	cursor.close();
	if(raw_Contacts is not None):
		for raw_contact in raw_Contacts:
			contact = Contact()
			contact.name = raw_contact[0]
			contact.email = raw_contact[1]
			contact.id = raw_contact[2]
			contact.contact_uid = raw_contact[3]
			contact.phone = raw_contact[4]
			contact.hobbies = raw_contact[5]
			contact.interestedin = raw_contact[6]
			contact.currentstatus = raw_contact[7]
			contact.maritalstatus = raw_contact[8]
			contact.contact_of = raw_contact[9]
			contact.last_updated = raw_contact[10]
			contact.image = raw_contact[11]
			contacts.append(contact)
	onlineUsers = _getOnlineUsers()
	return render(request,'DatingApp/MainPage.html',{'user':request.user,'contacts':contacts,'onlineUsers':onlineUsers})
Exemple #2
0
def UpdateUserDetails(request):
	error = ''
	success = 0
	templateName = 'DatingApp/ProfilePage.html'
	user = None
	line = 0
	image = None
	if(request.POST):
		try:
			if('img' in request.FILES):
				image = request.FILES['img']
			user = request.user
			name = request.POST.get('name') 
			dob = request.POST.get('dob')
			address = request.POST.get('address')
			gender = request.POST.get('gender')
			phone = request.POST.get('phone')
			hobbies = request.POST.get('hobbies')
			interestedIn = request.POST.get('interestedIn',-1)
			currentStatus = request.POST.get('currentStatus')
			maritalStatus = request.POST.get('maritalStatus',-1)
			user = User.objects.get(username=request.user.username,uid=request.user.uid)
			user.name = name
			user.dob = datetime.strptime(dob,'%Y-%m-%d').isoformat()
			user.address = address
			user.gender = gender
			user.save()
			
			contact = Contact.objects.filter(contact_uid=user.uid)[:1]

			if(contact is None):
				#fileName = request.POST.get('img')
				contact = Contact(phone=phone,hobbies=hobbies,currentstatus=currentStatus,interestedin=interestedIn,maritalstatus=maritalStatus,contact_uid=user.uid)
				
			else:
				contact.phone=phone
				contact.hobbies=hobbies
				contact.currentstatus=currentStatus
				contact.interestedin=interestedIn
				contact.maritalstatus=maritalStatus

			
				
			if(image is not None):
				imageName = SetProfilePic(image,contact)
				if(len(imageName)>0 and imageName is not None):
					contact.image = imageName
			contact.save()
			success = 1
		except:
			error = sys.exc_info[0]
			#return render(request,'DatingApp/ProfilePage.html',{'error':error})

		if(success == 1):
			return HttpResponseRedirect('/MainPage/')

	return render(request,'DatingApp/ProfilePage.html',{'error':error,'user':user,'contact':contact})