From 98e83d8ffc9cc31986fb2672140aed005480cddb Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Tue, 27 Jul 2010 01:16:48 +0200 Subject: Add category manipulation support --- controller.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'controller.py') diff --git a/controller.py b/controller.py index 6db7b31..64b7af7 100644 --- a/controller.py +++ b/controller.py @@ -210,12 +210,19 @@ class ConstEdit (ConstAdd): return ConstAdd.POST(self) class Cat: - def GET(self, id = '/'): - if id: - id = id[1:] + def GET(self): + categories = Category.query.order_by(Category.name).all() + + return render("cats", cats = categories) + + def POST(self): + for id, name in web.input().iteritems(): + if id.startswith("n-"): + Category(name = name) + else: + Category.get(id).name = name - if not id: return "Add new cat" - else: return "Edit cat " + id + raise web.seeother("/") class FourOhFour: """ -- cgit v1.2.3-54-g00ecf