Ejemplo n.º 1
0
 def GET(self):
     i = web.input()
     pol = dist2pol(i.dist)
     src = get_captcha_src(pol)
     if src:
         wyr = forms.wyrform()
         set_captcha(wyr, src)
         return '<tr><td colspan=3><label for="captcha">Verification</label>'+ wyr.captcha.pre + wyr.captcha.render()+'</td></tr>'
Ejemplo n.º 2
0
 def GET(self, form=None):
     if not form:
         form = forms.wyrform()
         fill_user_details(form)
         add_captcha(form)
         
     useremail = helpers.get_loggedin_email() or helpers.get_unverified_email()    
     msg, msg_type = helpers.get_delete_msg()
     return render.writerep(form, useremail=useremail, msg=msg)
Ejemplo n.º 3
0
 def GET(self, wf=None):
     u = helpers.get_user()
     uemail = u and u.email
     if not wf:
 	    #create a new form and initialize with current user details
         wf = forms.wyrform()
 	    u and fill_user_details(wf, u)
 	captcha_html = prepare_for_captcha(wf)
 	msg, msg_type = helpers.get_delete_msg()
 	return render.writerep(wf, useremail=uemail, captchas=captcha_html, msg=msg)
Ejemplo n.º 4
0
 def POST(self):
     i = web.input()
     wyrform = forms.wyrform()
     if wyrform.validates(i):
         auth.assert_login(i)
         try:
             status = self.save_and_send_msg(i, wyrform)
         except CaptchaException:
             msg, msg_type = helpers.get_delete_msg()
             return render.writerep(wyrform, msg)
         else:
             if status:
                 p = db.select('politician', what='firstname, middlename, lastname',
                                 where='id=$self.pol', vars=locals())[0]
                 polstr = '<a href="/p/%s">%s %s %s</a>' % (self.pol, p.firstname, p.middlename, p.lastname)  
                 helpers.set_msg('Your message has been sent to %s.' % polstr)
             else:
                 helpers.set_msg('Sorry, your message has NOT been sent.', 'error')
         raise web.seeother('/')
     else:
         return self.GET(wyrform)
Ejemplo n.º 5
0
 def POST(self):
     def pol_link(polid):
         p = db.select('politician', what='firstname, middlename, lastname',
                         where='id=$polid', vars=locals())[0]
         return '<a href="/p/%s">%s %s %s</a>' % (polid, p.firstname or '',
                         p.middlename or '', p.lastname or '')
             
 	i = web.input()
 	wf = forms.wyrform()
 	pols = getpols(i.zip5, i.zip4, i.addr1+i.addr2)
 	captcha_needed = require_captcha(i, pols)
 	if not wf.validates(i) or captcha_needed:
         if captcha_needed: wf.valid, wf.note = False, 'Please fill the captcha below'
 	    wf.fill(i)
 	    return self.GET(wf)
 	else:
 	    uid = auth.assert_login(i)
 	    update_user_details(i, uid)
 	    env = simplejson.loads(i.get('captcha_env', '{}'))
 	    status = writerep.send_msgs(uid, i, source_id='wyr', pols=pols, env=env)
 	    pol_str = ", ".join([pol_link(p) for p in pols])
 	    helpers.set_msg('Your message has been sent to %s' % pol_str)
 	    raise web.seeother('/')
Ejemplo n.º 6
0
 def GET(self):
     i = web.input()
     pols = dist2pols(i.get('dist'))
     wf = forms.wyrform()
     captcha_html = prepare_for_captcha(wf, pols)
     return captcha_html