Exemplo n.º 1
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_('Your changes have been saved.'))
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', title=_('Edit Profile'),
                           form=form)
Exemplo n.º 2
0
def edit_profile():
    form = EditProfileForm()
    if form.validate_on_submit():
        current_user.name = form.name.data
        current_user.location = form.location.data
        current_user.about_me = form.about_me.data
        db.session.add(current_user)
        flash('Your profile has been updated')
        return redirect(url_for('.user', username=current_user.username))
    form.name.data = current_user.name
    form.location.data = current_user.location
    form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', form=form)
Exemplo n.º 3
0
def edit_profile():
    # form = ...(current_user.username) позволяет использовать метод проверки имени пользвателя 
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_('Ваши изменения сохранены.'))
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', title=_('Edit Profile'),
                           form=form)
Exemplo n.º 4
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_('Your changes have been saved.'))
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html',
                           title=_('Edit Profile'),
                           form=form)
Exemplo n.º 5
0
def edit_profile():

    form = EditProfileForm()

    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_('Changes saved succesfully!'))
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', form=form)
Exemplo n.º 6
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_('Les modifications ont été prises en compte.'))
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html',
                           title=_('Editer le profil'),
                           form=form)
Exemplo n.º 7
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_l('Ваши изменения были сохранены'))
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html',
                           title='Редактирование профиля',
                           form=form)
Exemplo n.º 8
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    #submit form
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash('Changes have been made')
        return redirect(url_for('main.user', username=current_user.username))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html',
                           title='Edit Profile',
                           form=form)
Exemplo n.º 9
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash("Your changes Have been saved")
        return redirect(url_for("main.edit_profile"))
    elif request.method == "GET":
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me

    return render_template("edit_profile.html",
                           form=form,
                           title="edit profile")
Exemplo n.º 10
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.email = form.email.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        return redirect(url_for('main.user', username=current_user.username))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.email.data = current_user.email
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html',
                           title=_('Edit Profile'),
                           form=form)
Exemplo n.º 11
0
def edit_profile(username):
    user = User.query.filter_by(username=username).first()
    form = EditProfileForm()
    if form.validate_on_submit():
        user.name = form.name.data
        user.location = form.location.data
        user.about_me = form.about_me.data
        db.session.add(user)
        db.session.commit()
        flash('Account updated', 'success')
        return redirect(url_for('main.profile', username=user.username))
    form.name.data = user.name
    form.location.data = user.location
    form.about_me.data = user.about_me
    return render_template('main/edit_profile.html', form=form)
Exemplo n.º 12
0
def edit_profile():
    form = EditProfileForm(current_user.username, current_user.email)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.email = form.email.data
        current_user.about_me = form.about_me.data
        db.session.add(current_user)
        db.session.commit()
        flash(_('Edited profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.email.data = current_user.email
        form.about_me.dat = current_user.about_me

    return render_template('main/edit_profile.html', form=form)
Exemplo n.º 13
0
def edit_profile():
    form = EditProfileForm()
    if form.validate_on_submit():
        current_user.real_name = form.real_name.data
        current_user.location = form.location.data
        current_user.about_me = form.about_me.data
        db.session.add(current_user)
        db.session.commit()
        flash(_('Your profile has been updated'), 'success')
        return redirect(url_for('main.user', username=current_user.username))

    form.real_name.data = current_user.real_name
    form.location.data = current_user.location
    form.about_me.data = current_user.about_me
    return render_template('user/edit_profile.html', form=form)
Exemplo n.º 14
0
def change_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.email = form.email.data
        db.session.commit()
        flash('Your changes have been saved.')
        return redirect(url_for('main.change_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.email.data = current_user.email
    return render_template('change_profile.html',
                           title='Edit Profile',
                           form=form,
                           label='Edit Profile')
Exemplo n.º 15
0
def edit_profile(
):  # use a resume format for jobseeker and their profile should be resume
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash('Your changes has been saved.')
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html',
                           title='Edit Profile',
                           form=form)
Exemplo n.º 16
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        print(form.bio.data)
        current_user.bio = form.bio.data
        current_user.username = form.username.data
        db.session.commit()
        flash("Your changes have been saved.")
        return redirect(url_for("main.edit_profile"))
    elif request.method == "GET":
        form.username.data = current_user.username
        form.bio.data = current_user.bio
    return render_template("edit_profile.html",
                           title=_("Edit Profile"),
                           form=form)
Exemplo n.º 17
0
def edit_profile():
    form = EditProfileForm()

    if form.validate_on_submit():
        if form.username.data:
            current_user.username = form.username.data

        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_('Your changes have been saved.'))
        return redirect(url_for('main.edit_profile'))

    return render_template('edit_profile.html',
                           title='Edit Profile',
                           form=form)
Exemplo n.º 18
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    # Validate username change
    if form.validate_on_submit():
        # If form is ok, commit
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash('Changes have been saved!')
        return redirect(url_for('main.edit_profile'))
    # When form is requested, fill in current profile info to the fields
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('main/profile_edit.html', form=form)
Exemplo n.º 19
0
def user(username):
    user = User.query.filter_by(username=username).first_or_404()
    posts = []
    return render_template('user.html',
                           posts=posts,
                           user=user,
                           form=EditProfileForm(current_user))
Exemplo n.º 20
0
def edit_profile():
    form = EditProfileForm(flask_login.current_user.username)
    if form.validate_on_submit():
        flask_login.current_user.username = form.username.data
        flask_login.current_user.about_me = form.about_me.data
        db.session.commit()
        flask.flash("Your changes have been saved.")
        return flask.redirect(
            flask.url_for("main.user",
                          username=flask_login.current_user.username))
    elif flask.request.method == "GET":
        form.username.data = flask_login.current_user.username
        form.about_me.data = flask_login.current_user.about_me
    return flask.render_template("main/edit_profile.html",
                                 title="Edit Profile",
                                 form=form)
Exemplo n.º 21
0
def user(username):
    user = User.query.filter_by(username=username).first_or_404()
    quals = user.qualifications
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.email = form.email.data
        db.session.commit()
        flash('Your changes have been saved.')
        return render_template('user.html', title='User',
                               form=form, user=user)
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.email.data = current_user.email
    return render_template('user.html', title='User',
                           form=form, user=user)
Exemplo n.º 22
0
def edit_profile():
    site_admins = current_app.config["SITE_ADMINS"]
    if current_user.id in site_admins:
        form = EditProfileFormAdmin()
        if form.validate_on_submit():
            user_id = form.user_id.data
            user = User.query.filter_by(id=user_id).first()

            if form.user_email.data:
                user.email = form.user_email.data
            if form.username.data:
                user.username = form.username.data.lower()
            if form.about_me.data:
                user.about_me = form.about_me.data
            db.session.commit()
            flash("Your changes have been saved.")
            return redirect(url_for("main.edit_profile"))
    else:
        form = EditProfileForm(current_user.username)
        if form.validate_on_submit():
            current_user.username = form.username.data.lower()
            current_user.about_me = form.about_me.data
            db.session.commit()
            flash("Your changes have been saved.")
            return redirect(url_for("main.edit_profile"))
        elif request.method == "GET":
            form.username.data = current_user.username.lower()
            form.about_me.data = current_user.about_me
    return render_template("main/edit_profile.html",
                           title="Edit profile",
                           form=form)
Exemplo n.º 23
0
def edit_profile():
    """
    Route for editing user profile
    """
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit(): #pylint: disable=no-else-return
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash('Your changes have been saved.')
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', title='Edit Profile',
                           form=form)
Exemplo n.º 24
0
def edit_profile():
    form = EditProfileForm(current_user.username, current_user.email)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.email = form.email.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash('Your changes have been saved.', 'success')
        return redirect(url_for('main.user', username=current_user.username))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.email.data = current_user.email
        form.about_me.data = current_user.about_me
    return render_template('users/edit_profile.html',
                           title='Edit Profile',
                           form=form)
Exemplo n.º 25
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.clientnet_user = form.clientnet_user.data
        current_user.clientnet_password = form.clientnet_password.data
        db.session.commit()
        flash('Your changes have been saved.', 'success')
        return redirect(url_for('main.edit_profile'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.clientnet_user.data = current_user.clientnet_user
        form.clientnet_password.data = current_user.clientnet_password
    return render_template('edit_profile.html',
                           title='Edit Profile',
                           form=form)
Exemplo n.º 26
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    if form.validate_on_submit():
        # A POST request is sent when the form is submitted
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_T("Your changes have been saved."))
        return redirect(url_for("main.edit_profile"))
    elif request.method == "GET":
        # A GET request is sent when the edit page is accessed
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template("edit_profile.html",
                           title="Edit Profile",
                           form=form)
Exemplo n.º 27
0
def edit_profile(username):
    """Render the user editing page.

    Keyword arguments:
    username -- the user's username
    """
    if not current_user.is_admin:
        flash("You don't have the rights to access this page.", 'danger')
        return redirect(url_for('main.dashboard'))

    user = User.query.filter_by(username=username).first_or_404()
    form = EditProfileForm(user.email)
    if form.validate_on_submit():
        user.first_name = form.first_name.data
        user.last_name = form.last_name.data
        user.birthdate = form.birthdate.data
        user.nickname = form.nickname.data
        user.email = form.email.data

        # Set account type
        user.is_customer = form.account_type.data == 'customer'
        user.is_observer = form.account_type.data == 'observer'
        user.is_bartender = form.account_type.data == 'bartender'
        user.is_admin = form.account_type.data == 'admin'

        if (form.password.data != ''):
            user.set_password(form.password.data)
        db.session.commit()
        flash('Your changes have been saved.', 'primary')
        return redirect(url_for('main.user', username=user.username))
    elif request.method == 'GET':
        form.first_name.data = user.first_name
        form.last_name.data = user.last_name
        form.birthdate.data = user.birthdate
        form.nickname.data = user.nickname
        form.email.data = user.email
        if user.is_observer:
            form.account_type.data = 'observer'
        if user.is_customer:
            form.account_type.data = 'customer'
        if user.is_bartender:
            form.account_type.data = 'bartender'
        if user.is_admin:
            form.account_type.data = 'admin'
    return render_template('edit_profile.html.j2',
                           title='Edit profile',
                           form=form)
Exemplo n.º 28
0
def edit_profile():
    form = EditProfileForm()
    if form.validate_on_submit():
        current_user.name = form.name.data
        current_user.location = form.location.data
        current_user.about_me = form.about_me.data
        try:
            db.session.add(current_user)
            db.session.commit()
        except:
            db.session.rollback()
        flash("Your profile has been updated")
        return redirect(url_for(".user", username=current_user.username))
    form.name.data = current_user.name
    form.location.data = current_user.location
    form.about_me.data = current_user.about_me
    return render_template("edit_profile.html", form=form)
Exemplo n.º 29
0
def edit_profile():
    form = EditProfileForm(original_username=current_user.username,
                           original_email=current_user.email)
    if form.validate_on_submit():
        current_user.username = form.username.data if form.username.data != "" else current_user.username
        current_user.email = form.email.data if form.email.data != "" else current_user.email
        if form.username.data != "" or form.email.data != "":
            current_user.commit()
            flash("Your changes have been saved.")
            return redirect(
                url_for("main.user", username=current_user.username))
    elif request.method == "GET":
        form.username.data = current_user.username
        form.email.data = current_user.email
    return render_template("edit_profile.html",
                           title="Edit Profile",
                           form=form)
Exemplo n.º 30
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    # 如果当前方法返回True,则提交表单数据到数据库
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        db.session.commit()
        flash(_('Your changes have been saved.'))
        return redirect(url_for('main.edit_profile'))
    # 这块代码主要是用与默认当前个人信息的,第一次进入当前界面
    # 会默认数据库中已有的数据,使用的GET请求
    # 如果提交表单出错,则代表POST提交,不执行
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', title=_('Edit Profile'),
                           form=form)
Exemplo n.º 31
0
def edit_profile():
    form = EditProfileForm(current_user.username)
    # Сохраняем изменения на странице
    if form.validate_on_submit():
        current_user.username = form.username.data
        current_user.about_me = form.about_me.data
        current_user.local_folder = form.local_folder.data
        dataBase.session.commit()
        flash('Your changes have been saved!')
        return redirect(url_for('main.edit_profile'))
    # Только зашли
    if request.method == 'GET':
        form.username.data = current_user.username
        form.about_me.data = current_user.about_me
    return render_template('edit_profile.html',
                           title='Изменить данные',
                           form=form)
Exemplo n.º 32
0
def edit_profile():
    #表单实例化
    form = EditProfileForm()
    #提交认证,表单数据赋值
    if form.validate_on_submit():
        current_user.name = form.name.data
        current_user.location = form.location.data
        current_user.about_me = form.about_me.data
        db.session.add(current_user)
        db.session.commit()
        flash('Your profile has been updated.')
        #更改后重定向到用户资料页
        return redirect(url_for('.user', username=current_user.username))
    form.name.data = current_user.name
    form.location.data = current_user.location
    form.about_me.data = current_user.about_me
    return render_template('edit_profile.html', form=form)
Exemplo n.º 33
0
def edit_profile():
    form = EditProfileForm()
    data = {
        "title": "编辑个人信息",
        "h": "编辑个人信息",
    }
    if form.validate_on_submit():
        current_user.name = form.name.data
        current_user.location = form.location.data
        current_user.about_me = form.about_me.data
        db.session.add(current_user)
        flash('你的个人信息已经更新')
        return redirect(url_for('.user', username=current_user.username))
    form.name.data = current_user.name
    form.location.data = current_user.location
    form.about_me.data = current_user.about_me
    return render_template('auth/common.html', form=form, data=data)
Exemplo n.º 34
0
def edit_profile(username):
    user = User.query.filter_by(username=username).first()
    if not user:
        abort(404)
    form = EditProfileForm(user=user)
    if form.validate_on_submit():
        user.email = form.email.data
        user.username = form.username.data
        user.name = form.name.data
        user.location = form.location.data
        user.about_me = form.about_me.data
        db.session.add(user)
        flash('个人信息已更新.')
        return redirect(url_for('.user', username=user.username))
    form.email.data = user.email
    form.username.data = user.username
    form.name.data = user.name
    form.location.data = user.location
    form.about_me.data = user.about_me
    return render_template('edit_profile.html', form=form, user=user)
Exemplo n.º 35
0
from flask import render_template, abort, flash, redirect, url_for, request, current_app