summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-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