diff options
Diffstat (limited to '')
-rw-r--r-- | controller.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/controller.py b/controller.py index 3d0ed1d..0e68491 100644 --- a/controller.py +++ b/controller.py @@ -186,6 +186,18 @@ class ConstAdd: def form(self): CE = ConstExpense + + # get the list of 'previous' expenses + prev_list = CE.query.filter(CE.next == None) + cur = self.get_expense() + + if cur.id is None: # empty + session.expunge(cur) + else: + prev_list = prev_list.filter(CE.id != cur.id) + + prev_list = prev_list.order_by(CE.description).values(CE.id, CE.description) + return Form( form.Textbox( "start", @@ -221,8 +233,7 @@ class ConstAdd: ), form.Dropdown( "prev", - iter.chain([(-1, '')], ConstExpense.query.filter(ConstExpense.next == None).\ - order_by(CE.description).values(CE.id, CE.description)) + iter.chain([(-1, '')], prev_list) ) ) |