def edCashFlow(id): ''' only called with a url link ''' cfData=CashFlow.query.filter_by(id=id).first() #make form and assign default values form=forms.addCashFlowForm(title=cfData.title,entVal=cfData.value,sDate=cfData.date, account=cfData.account_id, rType=cfData.recurType, rRate=cfData.recurRate, eDate=cfData.recurEnd, est=cfData.estimate) #add the account choices form.account.choices=[(acc.id,acc.title) for acc in Account.query.order_by('title')] if form.validate_on_submit(): # assign values and submit cfData.title=form.title.data cfData.value=form.entVal.data cfData.date=form.sDate.data cfData.account_id=form.account.data cfData.recurType=form.rType.data cfData.recurRate=form.rRate.data cfData.recurEnd=form.eDate.data cfData.estimate=form.est.data db.session.add(cfData) db.session.commit() flash("CashFlow %s Edit Success!"%cfData.title) return redirect(url_for('welcome')) return render_template('budg_CashFlow.html',cfData=cfData, form=form,edAdd="edit")
def adCashFlow(): '''add a cashflow to an account''' form=forms.addCashFlowForm() form.account.choices=[(acc.id,acc.title) for acc in Account.query.order_by('title')] if form.validate_on_submit(): create_a_thing(CashFlow,[form.account.data,form.title.data,form.entVal.data,form.sDate.data,\ form.rType.data,form.rRate.data,form.eDate.data,form.est.data]) return redirect(url_for('welcome')) return render_template('budg_CashFlow.html',form=form,edAdd="add")