@accounts.route('/account/transfer', methods=['GET', 'POST'])
@login_required
def add_transfer():

    current_user_id = session.get('logged_in_user')

    acc = Accounts(current_user_id)

    if request.method == 'POST':
        dict = __validate_transfer_form()
        for key in dict.keys(): exec(key + " = dict['" + key + "']")

        # 'heavier' checks
        if not error:
            # source and target the same?
            if not deduct_from_account == credit_to_account:
                # valid amount?
                if is_float(amount):
                    # is it a positive amount?
                    if float(amount) > 0:
                        # valid date?
                        if is_date(date):
                            # valid debit account?
                            if acc.is_account(account_id=deduct_from_account):
                                # valid credit account?
                                if acc.is_account(account_id=credit_to_account):

                                    # add a new transfer row
                                    acc.add_account_transfer(date=date, deduct_from_account=deduct_from_account,
                                                             credit_to_account=credit_to_account, amount=amount)

                                    # modify accounts
                                    acc.modify_account_balance(deduct_from_account, -float(amount))
                                    acc.modify_account_balance(credit_to_account, amount)

                                    flash('Monies transferred')

                                else: error = 'Not a valid target account'
                            else: error = 'Not a valid source account'
                        else: error = 'Not a valid date'
                    else: error = 'Provide a positive amount'
                else: error = 'Not a valid amount'
            else: error = 'Source and target accounts cannot be the same'

    accounts = acc.get_accounts()

    return render_template('admin_add_transfer.html', **locals())
Register a handler for a given service name.
dataset/ETHPy150Open radekstepan/FlaskBudget/presenters/accounts.py/add_transfer--crossover with--dataset/ETHPy150Open rduplain/wsgi_party/wsgi_party.py/WSGIParty.connect