Esempio n. 1
0
def index(request):
	lisUserProfile = {}
# 	print('begin')
# 	for user in lisUserProfile:
# 		print(user.company)
# 	print('finish')
	c = {'lisUserProfile':lisUserProfile,}
	if request.method == 'GET':
		return render(request, 'myapp/search-mentor.html', c)
	elif request.method == 'POST':
		try:
			keyword = request.POST['search']
			users = User.objects(Q(first_name__icontains=keyword) | Q(last_name__icontains=keyword))
			#search data
# 			lisUserProfile = UserProfile.objects(user_id__in=users,is_mentor=True)
			lisUserProfile = UserProfile.objects(user_id__in=users)
			
			listAllCurriculumn = Curriculumn.objects()
			listCurriculumn =Curriculumn.objects(name__icontains=keyword)
			c = {'lisUserProfile':lisUserProfile,'listCurriculumn':listCurriculumn,'listAllCurriculumn':listAllCurriculumn,'search':keyword}
			#get data from mongodb
			c.update(csrf(request))
			c.update(context_processors.user(request))
			return render_to_response("myapp/search-mentor.html", c)
		except Exception:
			c.update(csrf(request))
			c.update(context_processors.user(request))
			return render_to_response("myapp/search-mentor.html", c)
	return render(request, 'myapp/search-mentor.html', c)
Esempio n. 2
0
def index(request):
	lisUserProfile = UserProfile.objects
# 	print('begin')
# 	for user in lisUserProfile:
# 		print(user.images)
# 	print('finish')
	c = {'lisUserProfile':lisUserProfile,}
	if request.method == 'GET':
		return render(request, 'myapp/people-directory.html', c)
	elif request.method == 'POST':
		try:
			keyword = request.POST['keyword']
			users = User.objects(first_name__icontains=keyword)#search data
			lisUserProfile = UserProfile.objects(user_id__in=users)
			c = {'lisUserProfile':lisUserProfile,'keyword':keyword}
# 			profile = Profile()
# 			profile.name = 'Nusja Nawancali'
# 			profile.image_url='images/user3.png'
# 			profile.address='Phuket, Thailand'
# 			profile.location='Product Manager'
# 			profile.company='SomeCompany, Inc.'
# 			profile.save()

			#get data from mongodb
			c.update(csrf(request))
			c.update(context_processors.user(request))
			return render_to_response("myapp/people-directory.html", c)
		except Exception:
			c.update(csrf(request))
			c.update(context_processors.user(request))
			return render_to_response("myapp/people-directory.html", c)
	return render(request, 'myapp/test.html', c)