aboutsummaryrefslogtreecommitdiffstats
path: root/python/Dawn/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/Dawn/views.py')
-rw-r--r--python/Dawn/views.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/python/Dawn/views.py b/python/Dawn/views.py
index 9f0a0240..6f718422 100644
--- a/python/Dawn/views.py
+++ b/python/Dawn/views.py
@@ -4,6 +4,7 @@ from .models import ModelForm, BondDeal, Counterparties
from sqlalchemy import create_engine
from sqlalchemy.exc import IntegrityError
import pandas as pd
+from pandas.tseries.offsets import BDay
import os
import datetime
import redis
@@ -35,16 +36,14 @@ class BondForm(ModelForm):
@app.route('/trades/<int:tradeid>', methods=['GET', 'POST'])
@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:
- trade = BondDeal.query.get(tradeid)
- bond_form = BondForm(obj = BondDeal.query.get(tradeid))
- #we change the default to update
bond_form.action.choices = [('UPDATE', 'UPDATE'), ('CANCEL', 'CANCEL')]
old_ticket_name = trade.ticket
- else:
- trade = BondDeal()
- bond_form = BondForm()
- bond_form.cp_code.choices = cp_choices()
+ bond_form.trade_date.data = pd.datetime.today().date()
+ bond_form.settle_date.data = pd.datetime.today().date()+ 3 * BDay()
if bond_form.is_submitted():
if bond_form.validate():
bond_form.populate_obj(trade)