summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2011-02-15 04:52:50 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2011-02-15 04:52:50 +0100
commit4c2f57bc0323e7c61975d62b6bb443e2e3e32df5 (patch)
tree65137f8bc56f8b68e3b15ed08cb34f3a8549c276
parent85fe3f50a034131fb58178d626b842a311d6e13b (diff)
downloadkosten-4c2f57bc0323e7c61975d62b6bb443e2e3e32df5.tar.gz
kosten-4c2f57bc0323e7c61975d62b6bb443e2e3e32df5.tar.bz2
kosten-4c2f57bc0323e7c61975d62b6bb443e2e3e32df5.zip
... and also omit cycles :)
Diffstat (limited to '')
-rw-r--r--controller.py15
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)
)
)