Ejemplo n.º 1
0
def index(request):
	if request.method == 'GET':
		lisCategory =Category.objects()
		user=User.objects.get(username=str(request.user))
		mentor = Mentor.objects.get(user=user.id)
		cl = Curriculumn.objects(mentor=mentor).order_by('published_date')
		has_curriculum = False
		is_mentor = request.session['is_mentor']
		if len(cl):
			has_curriculum = True
		clTaken = 0
		clLike = 0
		mtTaken = 0
		mtLike = 0
		actTaken = 0
		actLike = 0
		mtTotal = 0
		actTotal = 0
		context = {	'user_id':user.id,
					'username':request.user,
					'cl':cl,
					'author':mentor.user.username,
					'author_id':mentor.user.id,
					'is_mentor':is_mentor,
					'clTaken':clTaken,
					'clLike':clLike,
					'mtTaken':mtTaken,
					'mtLike':mtLike,
					'actTaken':actTaken,
					'actLike':actLike,
					'mtTotal':mtTotal,
					'actTotal':actTotal,
					'has_curriculum':has_curriculum,
					'listCategory':lisCategory,}
		return render(request,'myapp/mentorview.html', context)
Ejemplo n.º 2
0
def index(request):
	if request.method == 'GET':
# 		cl = Curriculumn.objects(mentor=mentor)
# 		mentor = Mentor.objects.get(user=re)
# 		mentor_id = '5375ce146c02298c9af00e00'
		lisCategory =Category.objects()
		user_id=request.GET['user_id']
		user = User.objects.get(id=user_id)
		mentor = Mentor.objects.get(user=user)
		cl = Curriculumn.objects(mentor=mentor)
		has_curriculum = False
		is_mentor = False
		try:
			is_mentor = request.session['is_mentor']
		except Exception as e:
			print(e)
		if len(cl):
			has_curriculum = True
		clTaken = 0
		clLike = 0
		mtTaken = 0
		mtLike = 0
		actTaken = 0
		actLike = 0
		mtTotal = 0
		actTotal = 0
		for c in cl:
			if len(c.joined_user)>0 :
				for u in c.joined_user:
					print(u)
		context = {'user_id':user_id,
					'username':request.user,
					'cl':cl,
					'author':mentor.user.username,
					'author_id':user_id,
					'is_mentor':is_mentor,
					'clTaken':clTaken,
					'clLike':clLike,
					'mtTaken':mtTaken,
					'mtLike':mtLike,
					'actTaken':actTaken,
					'actLike':actLike,
					'mtTotal':mtTotal,
					'actTotal':actTotal,
					'has_curriculum':has_curriculum,
					'listCategory':lisCategory,}
		return render(request,'myapp/studentview.html', context)
Ejemplo n.º 3
0
def afterlogin(request):
	if request.method == 'GET':
		lisCategory =Category.objects()
		try:
			user=User.objects.get(username=str(request.user))
			user_id = user.id
		except Exception as e:
			c = {
					'error_message':e,
				}
		
		user = User.objects.get(id=user_id)
		mentor = Mentor.objects.get(user=user.id)
		cl = Curriculumn.objects(mentor=mentor)
		has_curriculum = False
		is_mentor = request.session['is_mentor']
		if len(cl):
			has_curriculum = True
		clTaken = 0
		clLike = 0
		mtTaken = 0
		mtLike = 0
		actTaken = 0
		actLike = 0
		mtTotal = 0
		actTotal = 0
		context = {'user_id':user_id,
					'username':request.user,
					'userlogged':user_id,
					'cl':cl,
					'author':mentor.user.username,
					'author_id':mentor.user.id,
					'is_mentor':is_mentor,
					'clTaken':clTaken,
					'clLike':clLike,
					'mtTaken':mtTaken,
					'mtLike':mtLike,
					'actTaken':actTaken,
					'actLike':actLike,
					'mtTotal':mtTotal,
					'actTotal':actTotal,
					'has_curriculum':has_curriculum,
					'listCategory':lisCategory,}
		return render(request,'myapp/mentorview.html', context)