def edTransfer(id): '''this should use add account template with filled in values''' #pick up the transferwe're editing tfData=Transfer.query.filter_by(id=id).first() form=forms.transferForm(title=tfData.title, value=tfData.value, f_account=tfData.f_account.id, t_account=tfData.t_account.id, date=tfData.date) #assign the drop downs form.f_account.choices=[(acc.id,acc.title) for acc in Account.query.order_by('title')] form.t_account.choices=[(acc.id,acc.title) for acc in Account.query.order_by('title')] if form.validate_on_submit(): #assign the values tfData.title=form.title.data tfData.value=form.value.data tfData.t_account=Account.query.filter_by(id=form.t_account.data).first() tfData.f_account=Account.query.filter_by(id=form.f_account.data).first() tfData.date=form.date.data db.session.add(tfData) db.session.commit() flash("Transfer edit complete") return redirect(url_for('welcome')) return render_template('budg_Transfer.html',form=form,edAdd="edit", tfData=tfData)
def adTransfer(): '''add a transfer to two accounts''' form=forms.transferForm() form.f_account.choices=[(acc.id,acc.title) for acc in Account.query.order_by('title')] form.t_account.choices=[(acc.id,acc.title) for acc in Account.query.order_by('title')] if form.validate_on_submit(): create_a_thing(Transfer,[form.title.data,form.value.data, form.f_account.data,form.t_account.data,form.date.data]) return redirect(url_for('welcome')) return render_template('budg_Transfer.html',form=form,edAdd="add")