aboutsummaryrefslogtreecommitdiffstats
path: root/python/Dawn/dawn.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/Dawn/dawn.py')
-rw-r--r--python/Dawn/dawn.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/python/Dawn/dawn.py b/python/Dawn/dawn.py
index 1f1e578b..f227593e 100644
--- a/python/Dawn/dawn.py
+++ b/python/Dawn/dawn.py
@@ -1,5 +1,6 @@
from flask import Flask, request, render_template
from models import db, ModelForm, BondDeal, Counterparties
+import pdb
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://dawn_user@debian/dawndb'
@@ -19,11 +20,19 @@ class BondForm(ModelForm):
@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)
+ bond_form = BondForm()
+ bond_form.counterparty.choices = list_counterparties()
+ if bond_form.is_submitted():
+ if bond_form.validate():
+ bond = BondDeal()
+ bond_form.populate_obj(bond)
+ bond.dealid = 'uniqid'
+ db.session.add(bond)
+ db.session.commit()
+ return "Success!"
+ else:
+ print(bond_form.errors)
+ return render_template("trade_entry.html", form=bond_form)
if __name__=="__main__":
app.run(debug=True)