def POST_sign(self, pid): i = web.input() sf = forms.signform() tocongress = to_congress(pid) p = get_petition_by_id(pid) is_new = lambda sid: not isinstance(sid, str) get_new = lambda sid: int(web.lstrips(sid, "old_")) if tocongress: i.pid, i.ptitle, i.msg = pid, p.title, p.description wf = forms.wyrform() captcha_needed = require_captcha(i) wyr_valid = wf.validates(i) and not captcha_needed if captcha_needed: wf.valid, wf.note = False, "Please fill the captcha below" else: wf, wyr_valid = None, True if sf.validates(i) and wyr_valid: uid = auth.assert_login(i) signid = save_signature(i, pid, uid) if is_new(signid): user = helpers.get_user_by_id(uid) sendmail_to_signatory(user, pid) else: signid = get_new(signid) if tocongress: send_to_congress(uid, i, signid) query = urllib.urlencode(dict(url="/c/%s" % pid, title=p.title)) raise web.seeother("/share?%s" % query, absolute=True) else: return self.GET(pid, sf=sf, wf=wf)
def POST_sign(self, pid): i = web.input() sf = forms.signform() tocongress = to_congress(pid) p = get_petition_by_id(pid) is_new = lambda sid: not isinstance(sid, str) get_new = lambda sid: int(web.lstrips(sid, 'old_')) if tocongress: i.pid, i.ptitle, i.msg = pid, p.title, p.description wf = forms.wyrform() captcha_needed = require_captcha(i) wyr_valid = wf.validates(i) and not captcha_needed if captcha_needed: wf.valid, wf.note = False, 'Please fill the captcha below' else: wf, wyr_valid = None, True if sf.validates(i) and wyr_valid: uid = auth.assert_login(i) signid = save_signature(i, pid, uid) if is_new(signid): user = helpers.get_user_by_id(uid) sendmail_to_signatory(user, pid) else: signid = get_new(signid) if tocongress: send_to_congress(uid, i, signid) query = urllib.urlencode(dict(url='/c/%s' % pid, title=p.title)) raise web.seeother('/share?%s' % query, absolute=True) else: return self.GET(pid, sf=sf, wf=wf)
def POST(self): i = web.input() tocongress = i.get("tocongress", "off") == "on" pf, wf = forms.petitionform(), forms.wyrform() i.email = "*****@*****.**" # to make wf valid, find a better work around wyr_valid = not (tocongress) or wf.validates(i) captcha_needed = require_captcha(i) wyr_valid = wyr_valid and not captcha_needed if not pf.validates(i) or not wyr_valid: if captcha_needed: wf.valid, wf.note = False, "Please fill the captcha below" pf.fill(i), wf.fill(i) return self.GET(pf, wf) email = helpers.get_loggedin_email() if not email: return login().GET(i) create_petition(i, email) raise web.seeother("/%s" % i.pid)
def POST(self): i = web.input() tocongress = i.get('tocongress', 'off') == 'on' pf, wf = forms.petitionform(), forms.wyrform() i.email = '*****@*****.**' # to make wf valid, find a better work around wyr_valid = (not (tocongress) or wf.validates(i)) captcha_needed = require_captcha(i) wyr_valid = wyr_valid and not captcha_needed if not pf.validates(i) or not wyr_valid: if captcha_needed: wf.valid, wf.note = False, 'Please fill the captcha below' pf.fill(i), wf.fill(i) return self.GET(pf, wf) email = helpers.get_loggedin_email() if not email: return login().GET(i) create_petition(i, email) raise web.seeother('/%s' % i.pid)