def POST(self): try: model.login(web.input()) raise web.seeother(helper.site_url()) except ValueError as e: web.ctx.session.flash = "Invalid login" raise web.seeother(helper.site_url("/login"))
def POST(self): try: hash = model.shorten(web.input().url) except ValueError as e: web.ctx.session.flash = "Error shortening URL: %s" % e raise web.seeother(helper.site_url()) web.ctx.session.flash = ( 'Shortened URL <a target="_blank" href="' + helper.site_url("/" + hash) + '">' + helper.site_url("/" + hash) + "</a> created" ) raise web.seeother(helper.site_url())
def attach_url_data(url): url.hashed_url = helper.site_url('/'+encode_hash(url.id)) url.clicks = db.select('clicks', where="url_id=$url_id", vars={'url_id': url.id}, order='created ASC') return url
def decorator(self, *args, **kwargs): if not hasattr(web.ctx.session, "user_id"): raise web.seeother(helper.site_url("/login")) else: return func(self, *args, **kwargs)