示例#1
0
def user_info(user_id):
    user1 = User.query.filter_by(id=user_id).first()
    form = UpdateAccountForm()
    '''
	if current_user then it can see the form
	if not current_user then only observe
	+ after I've changed
	url_for('users.user_info', user=user.id) 
	rather than user=user aforewriiten stuff started working
	'''
    if form.validate_on_submit():
        if form.pic.data:
            pic_file = save_pic(form.pic.data)
            current_user.image_file = pic_file
        current_user.username = form.username.data
        current_user.email = form.email.data
        current_user.country = form.country.data
        db.session.commit()
        flash('You has altered you account!', 'primary')
        return redirect(url_for('users.account'))
    elif request.method == 'GET':  # if we don't send data + if we simply open page
        form.username.data = user1.username
        form.email.data = user1.email
        form.country.data = user1.country
    return render_template('user_info.html',
                           title='User info',
                           user=user1,
                           form=form)
示例#2
0
def account():
    form = UpdateAccountForm()
    if form.picture.data:
        picture_file = save_pic(form.picture.data)
        current_user.image_file = picture_file
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.email = form.email.data
        db.session.commit()
        flash('Account aggiornato', 'success')
        return redirect(url_for('users.account'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.email.data = current_user.email
    image_file = url_for('static',
                         filename='profile_pic/' + current_user.image_file)
    return render_template('account.html',
                           title='Account',
                           image_file=image_file,
                           form=form)
示例#3
0
def account():
    form = UpdateForm()
    if form.validate_on_submit():
        if form.profile_pic.data:
            pic_file = save_pic(form.profile_pic.data)
            current_user.img_file = pic_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('users.account'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.email.data = current_user.email
    img_file = url_for('static',
                       filename='profile_pics/' + current_user.img_file)
    return render_template('account.html',
                           title='Account',
                           img_file=img_file,
                           form=form)
示例#4
0
def account():
    form = UpdateAccountForm()
    if form.validate_on_submit():
        if form.pic.data:
            pic_file = save_pic(form.pic.data)
            current_user.image_file = pic_file
        current_user.username = form.username.data
        current_user.email = form.email.data
        current_user.country = form.country.data
        db.session.commit()
        flash('Your acc now is altered!', 'warning')
        return redirect(url_for('users.account'))
    elif request.method == 'GET':  # if we don't send data + if we simply open page
        form.username.data = current_user.username
        form.email.data = current_user.email
        form.country.data = current_user.country
    image_file = url_for('static', filename='pics/' + current_user.image_file)
    return render_template('account.html',
                           title='Account',
                           form=form,
                           image_file=image_file)