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

    error = None
    if request.method == 'POST':
        new_account_name, account_type, account_balance, current_user_id =\
        request.form['name'], request.form['type'], request.form['balance'], session.get('logged_in_user')

        # blank name?
        if new_account_name:
            # type?
            if account_type == 'asset' or account_type == 'liability':\
                # if balance blank, pass in 0
                if not account_balance: account_balance = 0
                # is balance a valid float?
                if is_float(account_balance):

                    acc = Accounts(current_user_id)
                    # already exists?
                    if not acc.is_account(account_slug=new_account_name):

                        # create new account
                        acc.add_account(name=new_account_name, type=account_type, balance=account_balance)

                        flash('Account added')

                    else: error = 'You already have an account under that name'
                else: error = 'The initial balance needs to be a floating number'
            else: error = 'The account needs to either be an asset or a liability'
        else: error = 'You need to provide a name for the account'

    return render_template('admin_add_account.html', **locals())
Shared settings for different debian based/derived distributions.
dataset/ETHPy150Open radekstepan/FlaskBudget/presenters/accounts.py/add_account--crossover with--dataset/ETHPy150Open chapmanb/cloudbiolinux/cloudbio/distribution.py/_setup_deb_general