Ejemplo n.º 1
0
def init_account(account_id):
    init_db()
    if db_session.query(Account).get(account_id) is None:
        acc = Account({ 'id': account_id, 'balance': 0 })
        db_session.add(acc)
        db_session.commit()
    db_session.close()
Ejemplo n.º 2
0
def schdule():
    if redirectLogin() != None:
        return redirectLogin()
    else:
        if request.method == "POST":
            date = request.form["date"]
            content = request.form["content"]

            s = Schedule(str(date), str(content))

            db_session.add(s)
            db_session.commit()
        return render_template("schedule.html", schedule=scheduleList())
Ejemplo n.º 3
0
def process_deposit(e):
    init_db()

    amount = e.data['amount']
    account_id = e.data['account_id']
    seq = e.sequence

    init_account(account_id)

    if valid_seq(account_id, seq):
        logger.info("processing deposit: {}".format(vars(e)))
        updoc = { Account.sequence: seq, Account.balance: Account.balance + amount }
        Account.query.filter_by(id=account_id).update(updoc)
        db_session.commit()
    db_session.close()
    return
Ejemplo n.º 4
0
def pmeb():
    if redirectLogin() != None:
        return redirectLogin()
    else:
        if request.method == 'POST':        
            date = request.form["date"]
            content = request.form["content"]
            money = request.form["money"]

            p = PMEB(str(date), str(content), int(money))

            db_session.add(p)
            db_session.commit()
                        
            return redirect(url_for("pmeb"))
        return render_template("pmeb.html", pmeb=pmebList())