diff options
Diffstat (limited to 'python/Dawn')
| -rw-r--r-- | python/Dawn/dawn.py | 32 | ||||
| -rw-r--r-- | python/Dawn/templates/counterparties.html | 47 | ||||
| -rw-r--r-- | python/Dawn/templates/edit_cp.html | 28 |
3 files changed, 100 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) diff --git a/python/Dawn/templates/counterparties.html b/python/Dawn/templates/counterparties.html new file mode 100644 index 00000000..f0b0f60a --- /dev/null +++ b/python/Dawn/templates/counterparties.html @@ -0,0 +1,47 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> + </head> + <body style="max-width:1800px; margin:0 auto"> + <table class="table table-striped"> + <thead> + <tr> + <td>CODE</td> + <td>Firm</td> + <td>Location</td> + <td>DTC Number</td> + <td>Sales Contact</td> + <td>Sales Phone</td> + <td>Valuation Contact1</td> + <td>Valuation Contact2</td> + <td>Valuation Contact3</td> + <td>Valuation Contact4</td> + <td>Valuation Note</td> + </tr> + </thead> + {% for cp in counterparties %} + <tr> + <td><a href="{{url_for('edit_counterparty',cpcode=cp.code)}}">{{cp.code}}</td> + <td>{{cp.name}}</td> + <td>{{cp.city}}, {{cp.state}}</td> + <td>{{cp.dtc_number if cp.dtc_number}}</td> + <td><a href="mailto:{{cp.sales_email}}">{{cp.sales_contact if cp.sales_contact}}</a></td> + <td>{{cp.sales_phone if cp.sales_phone}}</td> + <td>{% if cp.valuation_contact1 %} + <a href="mailto:{{cp.valuation_email1}}"> + {{cp.valuation_contact1}}</a>{% endif %}</td> + <td>{% if cp.valuation_contact2 %} + <a href="mailto:{{cp.valuation_email2}}">{{cp.valuation_contact2}}</a>{% endif %}</td> + <td>{% if cp.valuation_contact3 %} + <a href="mailto:{{cp.valuation_email3}}">{{cp.valuation_contact3}}</a>{% endif %}</td> + <td>{% if cp.valuation_contact4 %} + <a href="mailto:{{cp.valuation_email4}}">{{cp.valuation_contact4}}</a>{% endif %}</td> + <td>{{cp.notes if cp.notes}}</td> + <td> + </tr> + {% endfor %} + </table> + </body> +</html> diff --git a/python/Dawn/templates/edit_cp.html b/python/Dawn/templates/edit_cp.html new file mode 100644 index 00000000..49fc0f66 --- /dev/null +++ b/python/Dawn/templates/edit_cp.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> + </head> + <body style="max-width:1024px; margin:0 auto"> + <form method="POST" class="form-horizontal" action="/" enctype="multipart/form-data"> + {% for field in form %} + <div class="form-group"> + {% if field.type != 'CSRFTokenField' %} + <label class="control-label col-md-2" for="{{ field.id }}"> + {{ field.label.text }} + </label> + {% endif %} + <div class="col-md-3"> + {{ field(class_="form-control") }} + </div> + </div> + {% endfor %} + <div class="form-group"> + <div class="col-md-offset-2 col-md-3"> + <button type="submit" class="btn btn-default">Submit</button> + </div> + </div> + </form> + </body> +</html> |
