Пример #1
0
def edit(username):
    account = Account.find_account(username)
    generated_password = generate_random_password()
    form = AccountForm(obj=account)

    form.role.default = account.role
    form.process()

    if form.validate_on_submit():
        form.populate_obj(account)

        db.session.commit()

        flash(f'Account updated for { account.username }', 'success')
    else:
        flash('Account not modified', 'danger')
        print('==================== ERRORS: edit() ================')
        for err in form.errors:
            print(err)
        return render_template('pages/write_account.html',
                               form=form,
                               account=account,
                               generated_password=generated_password)

    return redirect(url_for('it.accounts_page'))
Пример #2
0
def edit_page(username):
    account = Account.find_account(username)
    generated_password = generate_random_password()

    if not account:
        flash('User does not exist', 'danger')
        return redirect(url_for('it.accounts_page'))

    form = AccountForm(obj=account)

    form.role.default = account.role
    form.process()

    return render_template('pages/write_account.html',
                           form=form,
                           account=account,
                           generated_password=generated_password)