Exemplo n.º 1
0
def login():
	try:
		name = request.form['name']
		birthday = request.form['birthday']
		phone = request.form['phone']
                                                    
		user = queries.get_valid_user(name, birthday, phone)
                
		if user is None:
			teacher = queries.get_valid_teacher(name, birthday, phone)
			if teacher is None:
				raise
			else:
				if 'pushtoken' in request.form:
					queries.update_pushtoken_teacher(teacher.id, request.form['pushtoken'])
				if 'model' in request.form:
					queries.update_phone_model_teacher(teacher.id, request.form['model'])
				count = queries.count_unanswer_question(teacher.id)
				evaluation = queries.get_score_evaluation(teacher.id)
				return render_template('login_teacher.json', 
					teacher=teacher, count=count, evaluation=evaluation)
		else:
			if 'pushtoken' in request.form:
				queries.update_pushtoken_user(user.id, request.form['pushtoken'])
			if 'model' in request.form:
				queries.update_phone_model_user(user.id, request.form['model'])
			count = queries.count_unconfirm_question(user.id)
			return render_template('login.json', user=user, count=count)
	except Exception, e:
		print e
		return render_template('error.json')
Exemplo n.º 2
0
def get_unconfirm_count():
	try:
		user_id = int(request.form['user_id'])
		count = auth_queries.count_unconfirm_question(user_id)
		return render_template('count.json', count=count)
	except Exception, e:
		print e
		return render_template('error.json')