diff options
Diffstat (limited to 'python/Dawn')
| -rw-r--r-- | python/Dawn/views.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/python/Dawn/views.py b/python/Dawn/views.py index e052e11f..12a943d0 100644 --- a/python/Dawn/views.py +++ b/python/Dawn/views.py @@ -42,13 +42,14 @@ class BondForm(ModelForm): @app.route('/trades/', defaults={'tradeid': None}, methods=['GET', 'POST']) def trade_manage(tradeid): trade = BondDeal.query.get(tradeid) if tradeid else BondDeal() - bond_form = BondForm(obj = trade) - bond_form.cp_code.choices = cp_choices() if tradeid: + bond_form = BondForm(obj = trade) bond_form.action.choices = [('UPDATE', 'UPDATE'), ('CANCEL', 'CANCEL')] old_ticket_name = trade.ticket - bond_form.trade_date.data = pd.datetime.today().date() - bond_form.settle_date.data = pd.datetime.today().date()+ 3 * BDay() + else: + bond_form = BondForm(trade_date = pd.datetime.today().date(), + settle_date = pd.datetime.today().date() + 3 * BDay()) + bond_form.cp_code.choices = cp_choices() if bond_form.is_submitted(): if bond_form.validate(): bond_form.populate_obj(trade) @@ -70,8 +71,8 @@ def trade_manage(tradeid): trade.ticket)) try: session.commit() - except IntegrityError: - print("TODO: fix this") + except IntegrityError as e: + print(e) finally: q = get_queue() q.rpush('trades', simple_serialize(trade)) |
