Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
57 lines (48 sloc) 1.41 KB
import web
web.template.Template.globals['datestr'] = web.datestr
web.template.Template.globals['len'] = len
db = web.database(dbn='postgres', db='rtask', user='postgres', pw='x')
render = web.template.render('templates/', cache=False)
now = web.SQLLiteral('now()')
urls = (
'/', 'main',
'/add', 'add',
'/edit', 'edit',
'/reset', 'reset'
class main:
def GET(self):
q = "and completed is null and (postponed_until is null or postponed_until < now()) and someday is null"
focus ='tasks', where="stalled='f' " + q)
stalled ='tasks', where="stalled='t' " + q)
return render.index(focus, stalled)
class add:
def POST(self):
i = web.input('name')
raise web.seeother('/')
class edit:
def POST(self):
i = web.input('id')
out =
if i.get('name'): =
elif i.get('stall'):
elif i.get('finished'):
out.completed = now
out.gave_up = (i.finished=='gaveup')
elif i.get('postpone'):
if i.postpone == 'someday':
out.someday = True
out.postponed_until = web.SQLLiteral('now() + ' + web.sqlquote(i.postpone))
db.update('tasks', where="id=$id", vars=i, **out)
raise web.seeother('/')
class reset:
def POST(self):
db.update('tasks', where="stalled='t'", stalled=False)
raise web.seeother('/')
app = web.application(urls, globals())
if __name__ == "__main__":