示例#1
0
def user_edit(user_id):

    user = User.query.get(user_id)
    form = UserForm(request.form, user)

    if request.method == 'POST':
        if form.validate():
            form.populate_obj(user)
            db.session.commit()

            flash('Data saved successfully', 'success')
            return redirect(url_for('web.user_index'))

        flash('Data not valid, please review the fields')
    return render_template('users/edit.html', form=form, user_id=user_id)
示例#2
0
def user_edit(user_id):

    user = User.query.get(user_id)
    form = UserForm(request.form, user)

    if request.method == 'POST':
        if form.validate():
            form.populate_obj(user)
            db.session.commit()

            flash('Data saved successfully', 'success')
            return redirect(url_for('web.user_index'))

        flash('Data not valid, please review the fields')
    return render_template('users/edit.html', form=form, user_id=user_id)
示例#3
0
def user_add():
    form = UserForm(request.form)
    if request.method == 'POST':
        if form.validate():
            user = User()
            form.populate_obj(user)
            user.store_password_hashed(form.password.data)
            db.session.add(user)
            db.session.commit()

            flash('Data saved successfully', 'success')
            return redirect(url_for('web.user_index'))

        flash('Data not valid, please review the fields')

    return render_template('users/add.html', form=form)
示例#4
0
def user_add():
    form = UserForm(request.form)
    if request.method == 'POST':
        if form.validate():
            user = User()
            form.populate_obj(user)
            user.store_password_hashed(form.password.data)
            db.session.add(user)
            db.session.commit()

            flash('Data saved successfully', 'success')
            return redirect(url_for('web.user_index'))

        flash('Data not valid, please review the fields')

    return render_template('users/add.html', form=form)
示例#5
0
def project_join(project_id):
    project = Project.query.get(project_id)
    form = UserForm(request.form)

    if form.validate_on_submit():
        user = User()
        form.populate_obj(user)
        db.session.add(user)
        db.session.commit()

        user.projects.append(project)
        db.session.commit()

        flash('Success', 'success')
        return redirect(url_for('web.project_view', project_id=project_id))

    return render_template('projects/join.html', project=project, form=form)
示例#6
0
def project_join(project_id):
    project = Project.query.get(project_id)
    form = UserForm(request.form)

    if form.validate_on_submit():
        user = User()
        form.populate_obj(user)
        db.session.add(user)
        db.session.commit()

        user.projects.append(project)
        db.session.commit()

        flash('Success', 'success')
        return redirect(url_for('web.project_view', project_id=project_id))

    return render_template('projects/join.html', project=project, form=form)
示例#7
0
def user_account():
    user_id = current_user.get_id()
    user = User.query.get(user_id)
    if not user:
        raise Exception('User not found')

    form = UserForm(request.form, user)
    if request.method == 'POST':
        if form.validate():
            form.populate_obj(user)
            user.store_password_hashed(form.password.data)
            db.session.commit()

            flash('Data saved successfully', 'success')
            return redirect(url_for('web.user_index'))

        flash('Data not valid, please review the fields')

    return render_template('users/account.html', form=form, user_id=user_id)
示例#8
0
def user_account():
    user_id = current_user.get_id()
    user = User.query.get(user_id)
    if not user:
        raise Exception('User not found')

    form = UserForm(request.form, user)
    if request.method == 'POST':
        if form.validate():
            form.populate_obj(user)
            user.store_password_hashed(form.password.data)
            db.session.commit()

            flash('Data saved successfully', 'success')
            return redirect(url_for('web.user_index'))

        flash('Data not valid, please review the fields')

    return render_template('users/account.html', form=form, user_id=user_id)