Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
def get_sender_email(msgid):
    uid = messages.get_sender_id(msgid)
    if uid:
        user = helpers.get_user_by_id(uid)
        if user: return user.email
Exemplo n.º 4
0
def get_sender_email(msgid):
    uid = messages.get_sender_id(msgid)
    if uid: 
        user = helpers.get_user_by_id(uid)
        if user: return user.email