コード例 #1
0
ファイル: api.py プロジェクト: AuroraSkywalker/watchdog
 def POST(self):
     i = web.input()
     pols = validate(i)
     uid = get_userid()
     i['ptitle'] = i.get('subject')
     i['addr1'], i['addr2'] = i.get('address'), ''
     i['state'] = i.district[:2]
     env = simplejson.loads(i.get('env', '{}'))
     msgids = writerep.send_msgs(uid, i, source_id='wyr', pols=pols, env=env)
     ret = {}
     for pol in msgids:
         ret[pol] = dict(msgid=msgids[pol], status='SENT')
     return ret
コード例 #2
0
 def POST(self):
     i = web.input()
     pols = validate(i)
     uid = get_userid()
     i['ptitle'] = i.get('subject')
     i['addr1'], i['addr2'] = i.get('address'), ''
     i['state'] = i.district[:2]
     env = simplejson.loads(i.get('env', '{}'))
     msgids = writerep.send_msgs(uid,
                                 i,
                                 source_id='wyr',
                                 pols=pols,
                                 env=env)
     ret = {}
     for pol in msgids:
         ret[pol] = dict(msgid=msgids[pol], status='SENT')
     return ret
コード例 #3
0
ファイル: wyrapp.py プロジェクト: ChunHungLiu/watchdog-1
 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('/')