Beispiel #1
0
    def GET(self, pid, sf=None, wf=None):
        i = web.input()
        pid = pid.rstrip("/")
        p = get_petition_by_id(pid)
        if not p:
            raise web.notfound()

        options = ["unsign", "edit", "delete"]
        if i.get("m", None) in options:
            handler = getattr(self, "GET_" + i.m)
            return handler(pid)

        if not sf:
            sf = forms.signform()
            fill_user_details(sf)

        captcha_html = ""
        if to_congress(pid):
            if not wf:
                wf = forms.wyrform()
                fill_user_details(wf)
            captcha_html = wyrapp.prepare_for_captcha(wf)

        if "tid" in i:
            set_referrer_cookie(i.tid, pid)
            raise web.seeother("/%s" % pid)

        u = web.storage()
        u.email = helpers.get_loggedin_email() or helpers.get_unverified_email()
        u.isauthor = is_author(u.email, pid)
        u.issignatory = is_signatory(u.email, pid)
        p.isdraft = is_draft(p)
        p.signatory_count = get_num_signs(pid)
        msg, msg_type = helpers.get_delete_msg()
        return render.petition(p, u, sf, wf, captcha_html, msg)
Beispiel #2
0
    def GET(self, pid, sf=None, wf=None):
        i = web.input()
        pid = pid.rstrip('/')
        p = get_petition_by_id(pid)
        if not p: raise web.notfound()

        options = ['unsign', 'edit', 'delete']
        if i.get('m', None) in options:
            handler = getattr(self, 'GET_' + i.m)
            return handler(pid)

        if not sf:
            sf = forms.signform()
            fill_user_details(sf)

        captcha_html = ''
        if to_congress(pid):
            if not wf:
                wf = forms.wyrform()
                fill_user_details(wf)
            captcha_html = wyrapp.prepare_for_captcha(wf)

        if 'tid' in i:
            set_referrer_cookie(i.tid, pid)
            raise web.seeother('/%s' % pid)

        u = web.storage()
        u.email = helpers.get_loggedin_email() or helpers.get_unverified_email(
        )
        u.isauthor = is_author(u.email, pid)
        u.issignatory = is_signatory(u.email, pid)
        p.isdraft = is_draft(p)
        p.signatory_count = get_num_signs(pid)
        msg, msg_type = helpers.get_delete_msg()
        return render.petition(p, u, sf, wf, captcha_html, msg)
Beispiel #3
0
    def GET(self, pid, signform=None, wyrform=None):
        i = web.input()
        pid = pid.rstrip('/')
        p = get_petition_by_id(pid)
        if not p: raise web.notfound
        
        options = ['unsign', 'edit', 'delete']
        if i.get('m', None) in options:
            handler = getattr(self, 'GET_'+i.m)
            return handler(pid)

        p.signatory_count = get_num_signs(pid)
        if not signform:
            signform = forms.signform()
            fill_user_details(signform)
            
        if to_congress(pid) and not wyrform:
            wyrform = forms.wyrform()
            fill_user_details(wyrform)
            add_captcha(wyrform)

        if 'tid' in i: 
            set_referrer_cookie(i.tid, pid)
            raise web.seeother('/%s' % pid)
            
        msg, msg_type = helpers.get_delete_msg()
        useremail = helpers.get_loggedin_email() or helpers.get_unverified_email()
        isauthor = is_author(useremail, pid)
        issignatory = is_signatory(useremail, pid)
        return render.petition(p, signform, useremail, isauthor, issignatory, wyrform, msg)
Beispiel #4
0
    def GET(self, pid, signform=None, passwordform=None):
        i = web.input()
        
        options = ['signatories', 'unsign', 'edit', 'delete']
        if i.get('m', None) in options:
            handler = getattr(self, 'GET_'+i.m)
            return handler(pid)

        try:
            p = db.select('petition', where='id=$pid', vars=locals())[0]
        except:
            raise web.notfound
        
        p.signatory_count = db.query('select count(*) from signatory where petition_id=$pid',
                                        vars=locals())[0].count
        
        if not signform:
            signform = forms.signform()
            fill_user_details(signform, ['name', 'email'])
                                              
        if askforpasswd(p.owner_id) and not passwordform: passwordform = forms.passwordform()
        msg, msg_type = helpers.get_delete_msg()   
        return render.petition(p, signform, passwordform, msg)