예제 #1
0
파일: it.py 프로젝트: kmvdj23/HR-System
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 profile():
    form = AccountForm(obj=current_user)

    if form.validate_on_submit():
        form.populate_obj(current_user)
        current_user.save()

        return(redirect(url_for('main.profile')))

    return render_template('/pages/profile.html', form=form)
예제 #3
0
def signup():
    if(current_user.is_authenticated and current_user.is_active):
        return redirect(url_for('main.home'))

    form = AccountForm(request.form)

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

        account.password = password_encrypt(account.password)

        account.save()

        if login_user(account) and account.is_active():
            account.update_activity_tracking(request.remote_addr)
            return redirect(url_for('main.home'))

    return render_template('/pages/signup.html', form=form)
예제 #4
0
파일: it.py 프로젝트: kmvdj23/HR-System
def register():
    form = AccountForm()

    # Set required fields
    form.password.validators.append(DataRequired())
    form.confirm_pass.validators.append(DataRequired())

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

        db.session.add(account)
        db.session.commit()

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

    return redirect(url_for('it.accounts_page'))