コード例 #1
0
ファイル: petition.py プロジェクト: AuroraSkywalker/watchdog
    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)
コード例 #2
0
ファイル: petition.py プロジェクト: jdthomas/watchdog
    def GET(self, emailform=None, loadcontactsform=None):
        i = web.input()
        url = i.get('url', '/')
        title = i.get('title', 'The good government site with teeth')

        user_id = helpers.get_loggedin_userid()
        contacts = get_contacts(user_id)
        sender = helpers.get_user_by_email(helpers.get_loggedin_email() or helpers.get_unverified_email())

        page_or_petition = 'page'    
        if not emailform:
            emailform = forms.emailform()
            track_id, description = None, None
            if url.startswith('/c/') and url != '/c/':
                url = url.rstrip('/')
                pid = web.lstrips(url, '/c/')
                p = get_petition_by_id(pid)
                description = p and p.description
                track_id = helpers.get_trackid(user_id, pid)
                contacts = filter(lambda c: not is_signatory(c.email, pid), contacts)
                page_or_petition = 'petition'

            msg = render_plain.share_mail(title, url, sender, description, track_id)
            emailform.fill(subject=title, body=msg)

        loadcontactsform = loadcontactsform or forms.loadcontactsform()

        msg, msg_type = helpers.get_delete_msg()
        return render.share(title, url, emailform,
                            contacts, loadcontactsform, page_or_petition, msg)
コード例 #3
0
ファイル: petition.py プロジェクト: ChunHungLiu/watchdog-1
    def GET(self, emailform=None, loadcontactsform=None):
        i = web.input()
        url = i.get('url', '/')
        title = i.get('title', 'The good government site with teeth')

        user_id = helpers.get_loggedin_userid()
        contacts = get_contacts(user_id)
        sender = helpers.get_user_by_email(helpers.get_loggedin_email()
                                           or helpers.get_unverified_email())

        page_or_petition = 'page'
        isdraft = False
        if not emailform:
            emailform = forms.emailform()
            track_id, description = None, None
            if url.startswith('/c/') and url != '/c/':
                url = url.rstrip('/')
                pid = web.lstrips(url, '/c/')
                p = get_petition_by_id(pid)
                isdraft = is_draft(p)
                description = p and p.description
                track_id = helpers.get_trackid(user_id,
                                               pid) if not isdraft else None
                contacts = filter(lambda c: not is_signatory(c.email, pid),
                                  contacts)
                page_or_petition = 'petition'
            msg = render_plain.share_mail(title, url, sender, description,
                                          isdraft, track_id)
            emailform.fill(subject=title, body=msg)

        loadcontactsform = loadcontactsform or forms.loadcontactsform()

        msg, msg_type = helpers.get_delete_msg()
        return render.share(title, url, emailform, contacts, loadcontactsform,
                            page_or_petition, msg)
コード例 #4
0
ファイル: petition.py プロジェクト: jdthomas/watchdog
    def POST(self, input=None):
        i = input or web.input()
        tocongress = i.get('tocongress', 'off') == 'on'
        pform, wyrform = forms.petitionform(), forms.wyrform()
        i.email = '*****@*****.**' # to make wyrform valid, find a better work around
        wyr_valid = (not(tocongress) or wyrform.validates(i))
        
        if 'signid' in i:
            signid = i.signid
            send_to_congress(i, wyrform, signid)
            raise web.seeother('/%s' % i.pid)
            
        if not pform.validates(i) or not wyr_valid:
            return render.petitionform(pform, wyrform)

        email = helpers.get_loggedin_email()
        if not email:
            return login().GET(i)

        try:    
            create_petition(i, email, wyrform)
        except CaptchaException:
            msg, msg_type = helpers.get_delete_msg()
            return render.petitionform(pform, wyrform, msg) 
               
        raise web.seeother('/%s' % i.pid)
コード例 #5
0
ファイル: petition.py プロジェクト: ChunHungLiu/watchdog-1
    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)
コード例 #6
0
ファイル: petition.py プロジェクト: AuroraSkywalker/watchdog
    def GET(self, emailform=None, loadcontactsform=None):
        i = web.input()
        url = i.get("url", "/")
        title = i.get("title", "The good government site with teeth")

        user_id = helpers.get_loggedin_userid()
        contacts = get_contacts(user_id)
        sender = helpers.get_user_by_email(helpers.get_loggedin_email() or helpers.get_unverified_email())

        page_or_petition = "page"
        isdraft = False
        if not emailform:
            emailform = forms.emailform()
            track_id, description = None, None
            if url.startswith("/c/") and url != "/c/":
                url = url.rstrip("/")
                pid = web.lstrips(url, "/c/")
                p = get_petition_by_id(pid)
                isdraft = is_draft(p)
                description = p and p.description
                track_id = helpers.get_trackid(user_id, pid) if not isdraft else None
                contacts = filter(lambda c: not is_signatory(c.email, pid), contacts)
                page_or_petition = "petition"
            msg = render_plain.share_mail(title, url, sender, description, isdraft, track_id)
            emailform.fill(subject=title, body=msg)

        loadcontactsform = loadcontactsform or forms.loadcontactsform()

        msg, msg_type = helpers.get_delete_msg()
        return render.share(title, url, emailform, contacts, loadcontactsform, page_or_petition, msg)
コード例 #7
0
ファイル: petition.py プロジェクト: jdthomas/watchdog
    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)
コード例 #8
0
ファイル: petition.py プロジェクト: AuroraSkywalker/watchdog
 def GET(self, pf=None, wf=None):
     pf = pf or forms.petitionform()
     if not wf:
         # create a new form and initialize with current user details
         wf = forms.wyrform()
         u = helpers.get_user()
         u and fill_user_details(wf, u)
     captcha_html = wyrapp.prepare_for_captcha(wf)
     msg, msg_type = helpers.get_delete_msg()
     return render.petitionform(pf, wf, captchas=captcha_html, msg=msg)
コード例 #9
0
ファイル: petition.py プロジェクト: jdthomas/watchdog
    def GET(self):
        petitions = db.select(['petition', 'signatory'],
                    what='petition.id, petition.title, count(signatory.user_id) as signature_count',
                    where='petition.id = signatory.petition_id and petition.deleted is null',
                    group='petition.id, petition.title',
                    order='count(signatory.user_id) desc'
                    )

        msg, msg_type = helpers.get_delete_msg()
        return render.petition_list(petitions, msg)
コード例 #10
0
ファイル: petition.py プロジェクト: ChunHungLiu/watchdog-1
 def GET(self, pf=None, wf=None):
     pf = pf or forms.petitionform()
     if not wf:
         #create a new form and initialize with current user details
         wf = forms.wyrform()
         u = helpers.get_user()
         u and fill_user_details(wf, u)
     captcha_html = wyrapp.prepare_for_captcha(wf)
     msg, msg_type = helpers.get_delete_msg()
     return render.petitionform(pf, wf, captchas=captcha_html, msg=msg)
コード例 #11
0
ファイル: petition.py プロジェクト: AuroraSkywalker/watchdog
    def GET(self):
        petitions = db.select(
            ["petition", "signatory"],
            what="petition.id, petition.title, count(signatory.user_id) as signature_count",
            where="petition.deleted is null and petition.published is not null "
            "and petition.id = signatory.petition_id  and signatory.deleted is null",
            group="petition.id, petition.title",
            order="count(signatory.user_id) desc",
        )

        msg, msg_type = helpers.get_delete_msg()
        return render.petition_list(petitions, msg)
コード例 #12
0
ファイル: petition.py プロジェクト: ChunHungLiu/watchdog-1
    def GET(self):
        petitions = db.select(
            ['petition', 'signatory'],
            what=
            'petition.id, petition.title, count(signatory.user_id) as signature_count',
            where='petition.deleted is null and petition.published is not null '
            'and petition.id = signatory.petition_id  and signatory.deleted is null',
            group='petition.id, petition.title',
            order='count(signatory.user_id) desc')

        msg, msg_type = helpers.get_delete_msg()
        return render.petition_list(petitions, msg)
コード例 #13
0
ファイル: petition.py プロジェクト: jdthomas/watchdog
 def POST(self):
     i = web.input()
     lf, wf =  forms.loginform(), forms.wyrform()
     if not lf.validates(i):
         pf, sf = forms.petitionform(), forms.signupform()
         lf.fill(i), pf.fill(i), wf.fill(i)
         return render.petitionlogin(lf, sf, pf, wf)
         
     try:    
         create_petition(i, i.useremail, wf)
     except CaptchaException:
         msg, msg_type = helpers.get_delete_msg()
         pf= forms.petitionform()
         pf.fill(i)
         return render.petitionform(pf, wf, msg)    
         
     raise web.seeother('/%s' % i.pid)
コード例 #14
0
ファイル: petition.py プロジェクト: jdthomas/watchdog
 def POST(self):
     i = web.input()
     sf, wf = forms.signupform(), forms.wyrform()
     if not sf.validates(i):
         lf, pf = forms.loginform(), forms.petitionform()
         sf.fill(i), pf.fill(i), wf.fill(i)
         return render.petitionlogin(lf, sf, pf, wf)
     user = auth.new_user(i.email, i.password)
     helpers.set_login_cookie(i.email)
     try:
         create_petition(i, i.email, wf)
     except CaptchaException:
         msg, msg_type = helpers.get_delete_msg()
         pf = forms.petitionform()
         pf.fill(i)
         return render.petitionform(pf, wf, msg)
         
     raise web.seeother('/%s' % i.pid)
コード例 #15
0
ファイル: petition.py プロジェクト: christopherbdnk/watchdog
    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)
コード例 #16
0
ファイル: contacts.py プロジェクト: AuroraSkywalker/watchdog
 def GET(self):
     msg, msg_type = helpers.get_delete_msg()
     return render.import_contacts(msg)
コード例 #17
0
ファイル: webapp.py プロジェクト: christopherbdnk/watchdog
 def GET(self, form=None):
     form = form or forms.writerep()
     msg, msg_type = helpers.get_delete_msg()
     return render.writerep(form, msg=msg)
コード例 #18
0
ファイル: contacts.py プロジェクト: ChunHungLiu/watchdog-1
 def GET(self):
     msg, msg_type = helpers.get_delete_msg()
     return render.import_contacts(msg)