saving now works, remove exports completely
This commit is contained in:
4
README
4
README
@@ -1,8 +1,4 @@
|
|||||||
TODO:
|
TODO:
|
||||||
* make save button create a comparison set to use
|
|
||||||
(also consider how to clean / re-create db initial values from code -- easily could just drop/recreate per table, and only drop finance, not csets)
|
|
||||||
* then delete export button
|
|
||||||
|
|
||||||
|
|
||||||
CONSIDER in code:
|
CONSIDER in code:
|
||||||
* when we time the payment of GMHBA / HCF (and at what cadence) and include it in calcs better
|
* when we time the payment of GMHBA / HCF (and at what cadence) and include it in calcs better
|
||||||
|
|||||||
1
db.py
1
db.py
@@ -149,6 +149,7 @@ def update_finance(data):
|
|||||||
|
|
||||||
|
|
||||||
def insert_cset( data ):
|
def insert_cset( data ):
|
||||||
|
print( f"Saving: {data['vars']['name']}" )
|
||||||
conn = connect_db(False)
|
conn = connect_db(False)
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
cur.execute('''INSERT INTO comparison_set (
|
cur.execute('''INSERT INTO comparison_set (
|
||||||
|
|||||||
10
main.py
10
main.py
@@ -1,7 +1,7 @@
|
|||||||
# main.py
|
# main.py
|
||||||
from flask import Flask, render_template, request, redirect, url_for, Response
|
from flask import Flask, render_template, request, redirect, url_for, Response, jsonify
|
||||||
from calc import calculate_savings_depletion
|
from calc import calculate_savings_depletion
|
||||||
from db import init_db, get_finance_data, update_finance, get_budget_data, get_comp_set_data, get_comp_set_options
|
from db import init_db, get_finance_data, update_finance, get_budget_data, insert_cset, get_comp_set_data, get_comp_set_options
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import csv
|
import csv
|
||||||
@@ -10,6 +10,9 @@ from disp import FP_VAR
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
# core vars that we will save for comparisons
|
||||||
|
VARS= ( 'D_Salary', 'D_Num_fortnights_pay', 'School_Fees', 'Car_loan_via_pay', 'Car_loan', 'Car_balloon', 'Living_Expenses', 'Savings', 'Interest_Rate', 'Inflation', 'Mich_present', 'Overseas_trip', 'Mark_reno', 'D_leave_owed_in_days', 'D_TLS_shares', 'M_TLS_shares', 'D_CBA_shares', 'TLS_price', 'CBA_price', 'Overseas_trip_date', 'Mark_reno_date', 'Sell_shares', 'CBA', 'TLS' )
|
||||||
|
|
||||||
# Initialize the database
|
# Initialize the database
|
||||||
init_db()
|
init_db()
|
||||||
|
|
||||||
@@ -74,8 +77,7 @@ def index():
|
|||||||
|
|
||||||
@app.route('/save', methods=['POST'])
|
@app.route('/save', methods=['POST'])
|
||||||
def save():
|
def save():
|
||||||
for el in request.form:
|
insert_cset( request.get_json() )
|
||||||
print(f"SAVE: {el}={request.form[el]}")
|
|
||||||
return "200"
|
return "200"
|
||||||
|
|
||||||
@app.route('/update', methods=['POST'])
|
@app.route('/update', methods=['POST'])
|
||||||
|
|||||||
@@ -284,7 +284,8 @@
|
|||||||
$.ajax( {
|
$.ajax( {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: '/save',
|
url: '/save',
|
||||||
data: { 'vars': vars, 'savings_data' :savingsData },
|
contentType: 'application/json',
|
||||||
|
data: JSON.stringify( { 'vars': vars, 'savings_data' :savingsData } ),
|
||||||
success: function() { $('#save_modal').modal('hide'); } } )"
|
success: function() { $('#save_modal').modal('hide'); } } )"
|
||||||
>Save</button>
|
>Save</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user