Beispiel #1
0
def account():
    form = UpdateAccountForm()
    if form.validate_on_submit():
        current_user.first_name = form.first_name.data
        current_user.last_name = form.last_name.data
        current_user.email = form.email.data
        db.session.commit()
        return redirect(url_for('account'))
    elif request.method == 'GET':
        form.first_name.data = current_user.first_name
        form.last_name.data = current_user.last_name
        form.email.data = current_user.email
    return render_template('account.html', title='Account', form=form)
Beispiel #2
0
def account():
    form = UpdateAccountForm()  #import the form
    #if the form submitted fine
    if form.validate_on_submit():
        current_user.first_name = form.first_name.data
        current_user.last_name = form.last_name.data
        current_user.email = form.email.data
        db.session.commit()
        return redirect(url_for('home'))
    #else return the existing User's informations
    elif request.method == 'GET':
        form.first_name.data = current_user.first_name
        form.last_name.data = current_user.last_name
        form.email.data = current_user.email
    return render_template('account.html', title='Account', form=form)
Beispiel #3
0
def myaccount():
    form = UpdateAccountForm()
    if form.validate_on_submit():
        if form.picture.data:
            picture_file = save_pictureUser(form.picture.data)
            current_user.userPic = picture_file
        current_user.username = form.username.data
        current_user.email = form.email.data
        db.session.commit()
        flash('Your account information was updated successfully!', 'success')
        return redirect(url_for('myaccount'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.email.data = current_user.email
    return render_template('myAccount.html', title='My Account', form=form)
Beispiel #4
0
def account():
    form = UpdateAccountForm()
    update_fields = [form.first_name, form.last_name, form.email]
    if form.validate_on_submit():
        current_user.first_name = form.first_name.data
        current_user.last_name = form.last_name.data
        current_user.email = form.email.data
        db.session.commit()
    elif request.method == 'GET':
        form.first_name.data = current_user.first_name
        form.last_name.data = current_user.last_name
        form.email.data = current_user.email
    return render_template('account.html',
                           title='Account',
                           form=form,
                           fields=update_fields)
Beispiel #5
0
def account():
    """Using the UpdateAccountForm this pulls data from the Users table
    and applys this to the fields on screen. This data can then
    be changed and updated."""
    form = UpdateAccountForm()
    if form.validate_on_submit():
        current_user.first_name = form.first_name.data
        current_user.last_name = form.last_name.data
        current_user.email = form.email.data
        db.session.commit()
        return redirect(url_for('account'))
    elif request.method == 'GET':
        form.first_name = current_user.first_name
        form.last_name = current_user.last_name
        form.email = current_user.email
    return render_template('account.html', title='Account Page', form=form)
Beispiel #6
0
def account():
    form = UpdateAccountForm()
    if form.validate_on_submit():
        if form.picture.data:
            picture_file = save_picture(form.picture.data)
            current_user.image_file = picture_file
        current_user.username = form.username.data
        current_user.email = form.email.data
        db.session.commit()
        flash('Your account has been updated!', 'success')
        return redirect(url_for('account'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.email.data = current_user.email
    image_file = url_for('static', filename='profile_pics/' + current_user.image_file)
    return render_template('account.html', title='Account',
                           image_file=image_file, form=form)
Beispiel #7
0
def account():
    form = UpdateAccountForm()
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.email = form.email.data
        db.session.commit()
        flash('Your account has been succesfuly updated.', 'success')
        return redirect(url_for('account'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.email.data = current_user.email
    avatar_img = url_for('static',
                         filename='profile_pics/' + current_user.avatar_img)
    return render_template("account.html",
                           title='Profile',
                           avatar_img=avatar_img,
                           form=form)
Beispiel #8
0
def account():
    #Gets the form and it is passed on to the account html
	form = UpdateAccountForm()
    #Ensures that the entries as valid and commits them
	if form.validate_on_submit():
		current_user.first_name = form.first_name.data
		current_user.last_name = form.last_name.data
		current_user.username = form.username.data
		current_user.email = form.email.data
		db.session.commit()
		flash('You have successfully updated your details!')
		return redirect(url_for('account'))
	elif request.method == 'GET':
		form.first_name.data = current_user.first_name
		form.last_name.data = current_user.last_name
		form.username.data = current_user.username

	return render_template('account.html', title='Account', form=form)
Beispiel #9
0
def account():
    form = UpdateAccountForm()
    favou = Favou.query.filter_by(id=current_user.id).all()
    products = []
    for favourite in favou:
        product = Products.query.filter_by(
            productcode=favourite.productcode).first()
        products.append(product)
    if form.validate_on_submit():
        current_user.first_name = form.first_name.data
        current_user.last_name = form.last_name.data
        current_user.email = form.email.data
        db.session.commit()
        return redirect(url_for('account'))
    elif request.method == 'GET':
        form.first_name.data = current_user.first_name
        form.last_name.data = current_user.last_name
        form.email.data = current_user.email
    return render_template('account.html',
                           title='Account',
                           form=form,
                           products=products)
def account():
    form = UpdateAccountForm()
    if form.delete.data:
        temp = Users.query.filter_by(id=current_user.id).first()
        temp2 = Teams.query.filter_by(user_id=current_user.id).all()
        if temp2:
            for i in temp2:
                db.session.delete(i)
        db.session.delete(temp)
        db.session.commit()
        return redirect(url_for('register'))
    if form.validate_on_submit():
        current_user.first_name = form.first_name.data
        current_user.last_name = form.last_name.data
        current_user.email = form.email.data
        db.session.commit()
        return redirect(url_for('account'))
    elif request.method == 'GET':
        form.first_name.data = current_user.first_name
        form.last_name.data = current_user.last_name
        form.email.data = current_user.email
    return render_template('account.html', title='Account', form=form)
Beispiel #11
0
def account():
    form = UpdateAccountForm()
    if form.validate_on_submit():
        current_user.first_name = form.first_name.data.capitalize()
        current_user.last_name = form.last_name.data.capitalize()
        current_user.email = form.email.data
        current_user.soc_name = form.SocietyName.data
        db.session.commit()
        return redirect(url_for('account'))
    elif request.method == 'GET':
        form.first_name.data = current_user.first_name
        form.last_name.data = current_user.last_name
        form.email.data = current_user.email
        lists = Society.query.filter_by(uni_id=current_user.uni_id).all()
        names = []
        for i in range(int(len(lists))):
            temp = [lists[i].SocietyName, lists[i].SocietyName]
            names.append(temp)
        form.SocietyName.choices = names
    return render_template('account.html',
                           title='Account',
                           form=form,
                           creator=current_user)
Beispiel #12
0
def preferences():
    '''Update profile information'''

    form = UpdateAccountForm()
    if form.validate_on_submit():
        if form.profile_picture.data:
            profile_image = save_profile_picture(form.profile_picture.data)
            current_user.image_file = profile_image
        current_user.username = form.username.data
        current_user.email = form.email.data
        current_user.location = form.location.data
        db.session.commit()
        db.session.remove()
        flash('Account updated successfully.', 'success')
        return redirect(url_for('auth.profile', _external=True))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.email.data = current_user.email
        form.location.data = current_user.location
    profile_image = url_for('static', filename='images/{}'.format(
                            current_user.image_file))
    return render_template('auth/preferences.html',
                           image_file=profile_image, form=form)
Beispiel #13
0
def preferences():
    '''Update profile information'''

    form = UpdateAccountForm()
    if form.validate_on_submit():
        if form.profile_picture.data:
            pass
            # profile_image = save_profile_picture(form.profile_picture.data)
            # current_user.image_file = profile_image
        current_user.username = form.username.data
        current_user.email = form.email.data
        db.session.commit()
        flash('Account updated successfully.', 'success')
        return redirect(url_for('admin.profile'))
    elif request.method == 'GET':
        # Populate username and email upon page load.
        form.username.data = current_user.username
        form.email.data = current_user.email
    profile_image = url_for('static',
                            filename='images/{}'.format(
                                current_user.image_file))
    return render_template('admin/preferences.html',
                           image_file=profile_image,
                           form=form)