Example #1
0
def log_in():
	if g.user is not None:
		if g.user.is_authenticated():
			flash('Already logged in')
			return redirect(url_for('person_info', id = g.user.get_id()))
	
	form = LogInForm()
	if request.method == 'POST':
		if form.validate_on_submit():
			registered_user = get_person_by_id(form.PersonID.data, form.Password.data)
			if registered_user is None:
				flash('Username or Password is invalid' , 'error')
				return redirect(url_for('log_in'))
				
			if not registered_user.is_authenticated:
				flash('Please wait for an ADMIN to accept your sign up' , 'error')
				return redirect(url_for('log_in'))
				
			login_user(registered_user)
			flash('Logged in successfully')
			return redirect(url_for('home'))
		
	return render_template('log_in.html', 
		title = 'Log In',
		form = form)
Example #2
0
def sign_up():
	form = SignUpForm()
	if request.method == 'POST':
		if form.validate_on_submit():
			PersonID = form.PersonID.data
			FirstName = form.FirstName.data
			LastName = form.LastName.data
			Password = form.Password.data
			Department = form.Department.data
			Position = form.Position.data
			Office = form.Office.data
			PhoneNumber = form.PhoneNumber.data
			Email = form.Email.data
			
			Skill1 = form.Skill1.data
			Skill2 = form.Skill2.data
			Skill3 = form.Skill3.data
			
			Interest1 = form.Interest1.data
			Interest2 = form.Interest2.data
			
			user = Person(PersonID, FirstName, LastName, Password, Department, Position, Office, PhoneNumber, Email, Skill1, Skill2, Skill3, Interest1, Interest2)
			
			user = commit_to_db(user)
			
			registered_user = get_person_by_id(form.PersonID.data)
			login_user(registered_user)
			flash('Signed in successfully')
			return redirect(url_for('person_info', id = g.user.get_id()))
	
	return render_template('sign_up.html', 
		title = 'Sign Up',
		form = form)
Example #3
0
def delete_user():
	deleted_user = get_person_by_id(request.form['id'])
	full_name = deleted_user.FirstName + ' ' + deleted_user.LastName
	deleted_user.Confirmed = True
	delete_from_db(deleted_user)
	return jsonify({'full_name': full_name})
Example #4
0
def accept_user():
	accepted_user = get_person_by_id(request.form['id'])
	full_name = accepted_user.FirstName + ' ' + accepted_user.LastName
	accepted_user.Confirmed = True
	commit_to_db(accepted_user)
	return jsonify({'full_name': full_name})
Example #5
0
def person_info(id):
	person = get_person_by_id(id)
	contributed_to = get_contribution(contributor = id)
	return render_template('single_person.html', person = person, contributed_to = contributed_to)
Example #6
0
def load_user(id):
    return get_person_by_id(id)