diff options
Diffstat (limited to 'python/Dawn/dawn.py')
| -rw-r--r-- | python/Dawn/dawn.py | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/python/Dawn/dawn.py b/python/Dawn/dawn.py index 98ff330f..6d28d6dc 100644 --- a/python/Dawn/dawn.py +++ b/python/Dawn/dawn.py @@ -54,6 +54,10 @@ class BondForm(ModelForm): include_foreign_keys = True exclude = ['dealid', 'lastupdate'] #we generate it with a trigger at the server level +class CounterpartyForm(ModelForm): + class Meta: + model = Counterparties + @app.route('/', methods=['GET', 'POST']) def trade_entry(): bond_form = BondForm() @@ -74,7 +78,7 @@ def trade_entry(): @app.route('/trade/<int:tradeid>', methods=['GET', 'POST']) def trade_update(tradeid): trade = BondDeal() - bond_form = BondForm(obj = trade.query.get(tradeid)) + bond_form = BondForm(obj = BondDeal.query.get(tradeid)) bond_form.counterparty.choices = list_counterparties() if bond_form.is_submitted(): if bond_form.validate(): @@ -86,14 +90,28 @@ def trade_update(tradeid): @app.route('/blotter/') def list_trades(): - trade = BondDeal() - trade_list = trade.query.order_by(trade.trade_date) + trade_list = BondDeal.query.order_by(BondDeal.trade_date) return render_template('blotter.html', trades=trade_list.all()) +@app.route('/counterparties/') +def list_counterparties(): + cp_list = Counterparties.query.order_by(Counterparties.name) + return render_template('counterparties.html', counterparties = cp_list.all()) + +@app.route('/edit_cp/<cpcode>', methods=['GET', 'POST']) +def edit_counterparty(cpcode): + cp_form = CounterpartyForm(obj = Counterparties.query.get(cpcode)) + if cp_form.is_submitted(): + if cp_form.validate(): + cp = Counterparties() + cp_form.populate_obj(cp) + return + return render_template('edit_cp.html', form=cp_form) + if __name__=="__main__": db.init_app(app) - # db.drop_all(app=app) - # db.create_all(app=app) - # add_triggers() - # load_counterparties() + db.drop_all(app=app) + db.create_all(app=app) + add_triggers() + load_counterparties() app.run(debug=True) |
