summaryrefslogtreecommitdiff
path: root/controller.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2010-05-12 00:12:57 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2010-05-12 00:12:57 +0200
commit585e2750154a4b6816bb2a67aca02b1640a5c7d6 (patch)
tree7fdfb02f270f5f9a475113894e262a2093a4b55e /controller.py
parentdee13ef44876ada3f6f66d7267b384db62d0bcd1 (diff)
downloadkosten-585e2750154a4b6816bb2a67aca02b1640a5c7d6.tar.gz
kosten-585e2750154a4b6816bb2a67aca02b1640a5c7d6.tar.bz2
kosten-585e2750154a4b6816bb2a67aca02b1640a5c7d6.zip
Create new form each time
Diffstat (limited to 'controller.py')
-rw-r--r--controller.py50
1 files changed, 26 insertions, 24 deletions
diff --git a/controller.py b/controller.py
index f3059d4..4e488dd 100644
--- a/controller.py
+++ b/controller.py
@@ -52,30 +52,6 @@ class Add:
dformat = "%d.%m.%Y"
- form = form.Form(
- form.Textbox(
- "date",
- form.notnull,
- value = datetime.date.today().strftime(dformat)
- ),
- form.Textbox(
- "expense",
- form.notnull,
- ),
- form.Textbox(
- "description",
- form.notnull
- ),
- form.Dropdown(
- "category",
- map(op.itemgetter(0), sorted(Category.query.values(Category.name)))
- ),
- validators = map(lambda x: form.Validator(*x), (
- ("Date Format does not match", lambda f: datetime.datetime.strptime(f.date, Add.dformat)),
- ("Not a valid decimal", lambda f: decimal.Decimal(f.expense)),
- ))
- )
-
def GET(self):
return render("add", form = self.form())
@@ -92,6 +68,32 @@ class Add:
else:
return render("add", form = f)
+ @property
+ def form(self):
+ return form.Form(
+ form.Textbox(
+ "date",
+ form.notnull,
+ value = datetime.date.today().strftime(dformat)
+ ),
+ form.Textbox(
+ "expense",
+ form.notnull,
+ ),
+ form.Textbox(
+ "description",
+ form.notnull
+ ),
+ form.Dropdown(
+ "category",
+ map(op.itemgetter(0), sorted(Category.query.values(Category.name)))
+ ),
+ validators = map(lambda x: form.Validator(*x), (
+ ("Date Format does not match", lambda f: datetime.datetime.strptime(f.date, Add.dformat)),
+ ("Not a valid decimal", lambda f: decimal.Decimal(f.expense)),
+ ))
+ )
+
class Edit:
def GET(self, id):
return "Edit " + id