aboutsummaryrefslogtreecommitdiffstats
path: root/python/Dawn/dawn.py
blob: 1f1e578b24e29cdbc29ee758672e9dc0d2ace34f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from flask import Flask, request, render_template
from models import db, ModelForm, BondDeal, Counterparties

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://dawn_user@debian/dawndb'
app.config['SECRET_KEY'] = 'papa'
db.init_app(app)

def list_counterparties():
    return Counterparties.query.order_by('name').\
        with_entities(Counterparties.code, Counterparties.name)

# Base.metadata.create_all(engine)

class BondForm(ModelForm):
    class Meta:
        model = BondDeal
        include_foreign_keys = True

@app.route('/', methods=['GET', 'POST'])
def trade_entry():
    form = BondForm()
    form.counterparty.choices = list_counterparties()
    if form.validate_on_submit():
        return "Success!"
    return render_template("trade_entry.html", form=form)

if __name__=="__main__":
    app.run(debug=True)