diff options
-rw-r--r-- | controller.py | 8 | ||||
-rw-r--r-- | templates/pages/add.mako | 4 | ||||
-rw-r--r-- | templates/pages/edit.mako | 5 |
3 files changed, 15 insertions, 2 deletions
diff --git a/controller.py b/controller.py index 470bf1f..55baa09 100644 --- a/controller.py +++ b/controller.py @@ -137,7 +137,13 @@ class Edit (Add): exp = SingleExpense.get(id) self.get_expense = lambda *x: exp - return Add.POST(self) + if "changeB" in web.input(): + return Add.POST(self) + elif "deleteB" in web.input(): + web.ctx.orm.delete(exp) + self.return_() + else: + return self.GET(id) def return_(self): raise web.seeother("/") diff --git a/templates/pages/add.mako b/templates/pages/add.mako index c1f4ae7..3ce46fd 100644 --- a/templates/pages/add.mako +++ b/templates/pages/add.mako @@ -6,7 +6,9 @@ <form name="add_expense" method="post"> ${form.render()} - <input type="submit" /> + <%block name="form_buttons"> + <input type="submit" name="changeB" /> + </%block> </form> <%block name="heading"> diff --git a/templates/pages/edit.mako b/templates/pages/edit.mako index 37c93dd..1343136 100644 --- a/templates/pages/edit.mako +++ b/templates/pages/edit.mako @@ -3,3 +3,8 @@ <%block name="heading"> Bearbeite Kosteneintrag </%block> + +<%block name="form_buttons"> + <input type="submit" name="changeB" /> + <input type="submit" name="deleteB" value="Eintrag löschen" /> +</%block> |