예제 #1
0
def save_signature(i, pid, uid):
    where = "petition_id=$pid AND user_id=$uid"
    signed = db.select("signatory", where=where, vars=locals())
    share_with = (i.get("share_with", "off") == "on" and "N") or "A"
    update_user_details(i)
    if not signed:
        referrer = get_referrer(pid, uid)
        signid = db.insert(
            "signatory",
            user_id=uid,
            share_with=share_with,
            petition_id=pid,
            comment=i.get("comment"),
            referrer=referrer,
        )
        helpers.set_msg("Thanks for your signing! Why don't you tell your friends about it now?")
        return signid
    else:
        db.update(
            "signatory",
            where="user_id=$uid and petition_id=$pid",
            comment=i.get("comment"),
            deleted=None,
            vars=locals(),
        )
        helpers.set_msg("Your signature has been changed. Why don't you tell your friends about it now?")
        return "old_%s" % signed[0].id
예제 #2
0
    def POST(self):
        i = web.input()
        appdata = i.get('appdata', '||')
        email, share_url, title = appdata.split('|')
        if i.get('ResponseCode', '') == 'RequestApproved':
            consent = self.get_consent(i.ConsentToken)
            lid = consent.get('lid')
            delegatedToken = urllib.unquote(consent.get('delt'))
            url = 'https://livecontacts.services.live.com'
            url += '/users/@L@' + lid + '/rest/LiveContacts/Contacts'
            request = urllib2.Request(url)
            request.add_header('Content-Type',
                               'application/xml; charset=utf-8')
            request.add_header('Authorization',
                               'DelegatedToken dt="%s"' % delegatedToken)
            try:
                response = urllib2.urlopen(request)
            except:
                helpers.set_msg('Authorization Failed.')
            else:
                contacts = self.get_contacts(response)
                save_contacts(email, contacts, provider='MICROSOFT')

        query = urllib.urlencode(dict(url=share_url, title=title))
        raise web.seeother('/share?%s' % query)
예제 #3
0
 def POST_unsign(self, pid):
     i = web.input()
     now = datetime.now()
     db.update("signatory", deleted=now, where="petition_id=$pid and user_id=$i.user_id", vars=locals())
     msg = "Your signature has been removed for this petition."
     helpers.set_msg(msg)
     raise web.seeother("/%s" % pid)
예제 #4
0
def save_signature(i, pid, uid):
    where = 'petition_id=$pid AND user_id=$uid'
    signed = db.select('signatory', where=where, vars=locals())
    share_with = (i.get('share_with', 'off') == 'on' and 'N') or 'A'
    update_user_details(i)
    if not signed:
        referrer = get_referrer(pid, uid)
        signid = db.insert('signatory',
                           user_id=uid,
                           share_with=share_with,
                           petition_id=pid,
                           comment=i.get('comment'),
                           referrer=referrer)
        helpers.set_msg(
            "Thanks for your signing! Why don't you tell your friends about it now?"
        )
        return signid
    else:
        db.update('signatory',
                  where='user_id=$uid and petition_id=$pid',
                  comment=i.get('comment'),
                  deleted=None,
                  vars=locals())
        helpers.set_msg(
            "Your signature has been changed. Why don't you tell your friends about it now?"
        )
        return 'old_%s' % signed[0].id
예제 #5
0
    def GET(self):
        i = web.input()
        appid = i.get('appid').rstrip()
        email, url, title = i.get('appdata', '||').split('|')
        userhash = i.get('userhash')
        ts = i.get('ts')
        token = i.get('token')
        query = urllib.urlencode(dict(url=url, title=title))
        if not token:
            raise web.seeother('/share?%s' % query)
        #XXX: security verification etc..
        url = yahooLoginURL(email, '/WSLogin/V1/wspwtoken_login', token)
        try:
            resp = urllib2.urlopen(url)
        except:
            helpers.set_msg('Authorization Failed.')
            raise web.seeother('/share?%s' % query)

        content = resp.read()
        soup = BeautifulSoup(content)
        aurl = 'http://address.yahooapis.com/v1/searchContacts?format=json'
        wssid = soup.findAll('wssid')[0].contents[0]
        cookie = soup.findAll('cookie')[0].contents[0]
        cookie = cookie.strip()

        furl = aurl + '&fields=email,name&email.present=1&appid=%s&WSSID=%s' % (
            appid, wssid)
        req = urllib2.Request(furl)
        req.add_header('Cookie', cookie)
        req.add_header('Content-Type', 'application/json')
        response = urllib2.urlopen(req).read()
        contacts = self.get_contacts(response)
        save_contacts(email, contacts, provider='YAHOO')
        raise web.seeother('/share?%s' % query)
예제 #6
0
def create_petition(i, email):
    tocongress = i.get("tocongress", "off") == "on"
    i.pid = i.pid.replace(" ", "-")
    u = helpers.get_user_by_email(email)
    is_draft = "save" in i
    published = None if is_draft else datetime.now()
    try:
        db.insert(
            "petition",
            seqname=False,
            id=i.pid,
            title=i.ptitle,
            created=datetime.now(),
            published=published,
            description=i.msg,
            owner_id=u.id,
            to_congress=tocongress,
        )
    except:
        return

    if is_draft:
        msg = """Petition saved for publishing later."""
        helpers.set_msg(msg)
    else:
        create_first_signature(i, u.email)
예제 #7
0
 def POST_delete(self, pid):
     with db.transaction():
         title = db.select('petition', what='title', where='id=$pid', vars=locals())[0].title
         db.delete('signatory', where='petition_id=$pid', vars=locals())
         db.delete('petition', where='id=$pid', vars=locals())
     helpers.set_msg('Petition "%s" deleted' % (title))
     raise web.seeother('/')
예제 #8
0
    def GET(self):
        i = web.input()
        appid = i.get('appid').rstrip()
        email, url, title = i.get('appdata', '||').split('|')
        userhash = i.get('userhash')        
        ts = i.get('ts')        
        token = i.get('token')        
        query = urllib.urlencode(dict(url=url, title=title))
        if not token:
            raise web.seeother('/share?%s' % query)
        #XXX: security verification etc..
        url = yahooLoginURL(email, '/WSLogin/V1/wspwtoken_login', token)
        try:
            resp = urllib2.urlopen(url)
        except:
            helpers.set_msg('Authorization Failed.')
            raise web.seeother('/share?%s' % query)

        content = resp.read()
        soup = BeautifulSoup(content)        
        aurl = 'http://address.yahooapis.com/v1/searchContacts?format=json'
        wssid = soup.findAll('wssid')[0].contents[0]        
        cookie =soup.findAll('cookie')[0].contents[0]        
        cookie = cookie.strip()        

        furl = aurl + '&fields=email,name&email.present=1&appid=%s&WSSID=%s' % (appid, wssid)
        req = urllib2.Request(furl)
        req.add_header('Cookie', cookie)
        req.add_header('Content-Type', 'application/json')
        response = urllib2.urlopen(req).read()
        contacts = self.get_contacts(response)
        save_contacts(email, contacts, provider='YAHOO')
        raise web.seeother('/share?%s' % query)
예제 #9
0
 def POST(self):
     i = web.input()
     form = forms.writerep()
     if form.validates(i):
         print i
         try:
             dists = zip2rep.zip2dist(i.zipcode, i.addr1+i.addr2)
         except zip2rep.BadAddress:
             dists = []
         #print dists
         
         if len(dists) != 1:
             form = add_zip4(form)
             return self.GET(form)
         
         dist = dists[0]    
         captcha = ('captcha' not in i) and writerep.get_captcha_src(dist)
         if captcha: 
             form = add_captcha(form, captcha)
             return self.GET(form) 
             
         msg_sent = writerep.writerep(district=dist, **i)
         if msg_sent: helpers.set_msg('Your message has been sent.')
         raise web.seeother('/writerep')
     else:
         return self.GET(form)        
예제 #10
0
 def POST_delete(self, pid):
     now = datetime.now()
     title = db.select('petition',
                       what='title',
                       where='id=$pid',
                       vars=locals())[0].title
     db.update('petition', where='id=$pid', deleted=now, vars=locals())
     helpers.set_msg('Petition "%s" deleted' % (title))
     raise web.seeother('/')
예제 #11
0
 def POST_unsign(self, pid):
     i = web.input()
     now = datetime.now()
     db.update('signatory',
               deleted=now,
               where='petition_id=$pid and user_id=$i.user_id',
               vars=locals())
     msg = 'Your signature has been removed for this petition.'
     helpers.set_msg(msg)
     raise web.seeother('/%s' % pid)
예제 #12
0
def create_first_signature(i, email):
    tocongress = i.get('tocongress', 'off') == 'on'
    i.pid = i.pid.replace(' ', '-')
    u = helpers.get_user_by_email(email)
    signid = save_signature(i, i.pid, u.id)
    if tocongress: send_to_congress(u.id, i, signid)
    sendmail_to_signatory(u, i.pid)
    msg = """Congratulations, you've created your petition.
             Now share it with all your friends."""
    helpers.set_msg(msg)
예제 #13
0
    def GET_delete(self, pid):
        user_email = helpers.get_loggedin_email()
        if is_author(user_email, pid):
            msg = str(render_plain.confirm_deletion(pid))
            helpers.set_msg(msg)
        else:
            login_link = '<a href="/u/login">Login</a>'
            helpers.set_msg('Only author of this petition can delete it. %s if you are.' % login_link, msg_type='error')

        raise web.seeother('/%s' % pid)
예제 #14
0
 def POST_unsign(self, pid):
     i = web.input()
     now = datetime.now()
     db.update('signatory',
                     deleted=now,
                     where='petition_id=$pid and user_id=$i.user_id',
                     vars=locals())
     msg = 'Your signature has been removed for this petition.'
     helpers.set_msg(msg)
     raise web.seeother('/%s' % pid)
예제 #15
0
 def POST(self):
     i = web.input()
     emailform = forms.emailform()
     if emailform.validates(i):
         pid, msg, subject = i.pid, i.body, i.subject
         emails = [e.strip() for e in i.emails.strip(', ').split(',')]
         web.sendmail(config.from_address, emails, subject, msg)
         helpers.set_msg('Thanks for sharing this petition with your friends!')    
         raise web.seeother('/%s' % (pid))
     else:
         return self.GET(emailform=emailform)    
예제 #16
0
def create_first_signature(i, email):
    tocongress = i.get("tocongress", "off") == "on"
    i.pid = i.pid.replace(" ", "-")
    u = helpers.get_user_by_email(email)
    signid = save_signature(i, i.pid, u.id)
    if tocongress:
        send_to_congress(u.id, i, signid)
    sendmail_to_signatory(u, i.pid)
    msg = """Congratulations, you've created your petition.
             Now share it with all your friends."""
    helpers.set_msg(msg)
예제 #17
0
 def GET_delete(self, pid):
     user_email = helpers.get_loggedin_email()
     if is_author(user_email, pid):
         msg = str(render_plain.confirm_deletion(pid))
     elif user_email:
         msg = "You don't have permissions to delete this petition."
     else:
         login_link = '<a href="/u/login">Login</a>'
         msg = 'Only author of this petition can delete it. %s if you are.' % login_link
     helpers.set_msg(msg)
     raise web.seeother('/%s' % pid)
예제 #18
0
 def GET_delete(self, pid):
     user_email = helpers.get_loggedin_email()
     if is_author(user_email, pid):
         msg = str(render_plain.confirm_deletion(pid))
     elif user_email:
         msg = "You don't have permissions to delete this petition."
     else:
         login_link = '<a href="/u/login">Login</a>'
         msg = "Only author of this petition can delete it. %s if you are." % login_link
     helpers.set_msg(msg)
     raise web.seeother("/%s" % pid)
예제 #19
0
 def POST(self):
     p = web.input()
     pform = forms.petitionform()
     auth.assert_verified(p.email)
     if pform.validates(p):
         save_petition(p)
         helpers.set_login_cookie(p.email)
         msg = """Congratulations, you've created your petition. 
                 Now sign and share it with all your friends."""
         helpers.set_msg(msg)
         return web.seeother('/%s' % p.pid)
     else:
         return render.petitionform(pform)
예제 #20
0
 def GET_edit(self, pid):
     user_email = helpers.get_loggedin_email()
     if is_author(user_email, pid):
         p = db.select('petition', where='id=$pid', vars=locals())[0]
         pform = forms.petitionform()            
         pform.fill(email=user_email, pid=p.id, ptitle=p.title, pdescription=p.description)
         for i in pform.inputs:
             if i.id in ['pid', 'email']: i.attrs['readonly'] = 'true'
         title = "Edit petition"    
         return render.petitionform(pform, title, target='/c/%s?m=edit' % (pid))     
     else:
         login_link = '<a href="/login">Login</a>'
         helpers.set_msg('Only author of this petition can edit it. %s if you are.' % login_link, msg_type='error')
         raise web.seeother('/%s' % pid)
예제 #21
0
 def GET_edit(self, pid):
     user_email = helpers.get_loggedin_email()
     if is_author(user_email, pid):
         p = get_petition_by_id(pid)
         u = helpers.get_user_by_email(user_email)
         pform = forms.petitionform()
         pform.fill(userid=u.id, email=user_email, pid=p.id, ptitle=p.title, msg=p.description, tocongress=p.to_congress)
         cform = forms.wyrform()
         fill_user_details(cform)
         title = "Edit your petition"
         return render.petitionform(pform, cform, title, target='/c/%s?m=edit' % (pid))
     else:
         login_link = '<a href="/u/login">Login</a>'
         helpers.set_msg('Only author of this petition can edit it. %s if you are.' % login_link, msg_type='error')
         raise web.seeother('/%s' % pid)
예제 #22
0
 def POST(self):
     i = web.input()
     emailform, loadcontactsform = forms.emailform(), forms.loadcontactsform()
     if emailform.validates(i):
         url, msg, subject = i.url, i.body, i.subject
         emails = [e.strip() for e in i.emails.strip(", ").split(",")]
         u = helpers.get_user_by_email(helpers.get_loggedin_email() or helpers.get_unverified_email())
         from_address = u and "%s %s <%s>" % (u.fname, u.lname, u.email) or config.from_address
         for email in emails:
             web.sendmail(from_address, email, subject, msg)
         page_or_petition = url.startswith("/c/") and "petition" or "page"
         helpers.set_msg("Thanks for sharing this %s with your friends!" % page_or_petition)
         raise web.seeother(url)
     else:
         return self.GET(emailform=emailform, loadcontactsform=loadcontactsform)
예제 #23
0
 def GET_unsign(self, pid):
     i = web.input()
     user = helpers.get_user_by_email(i.email)
     
     if user:
         signatory = db.select('signatory', where='petition_id=$pid and user_id=$user.id', vars=locals())
     
     if not (user and signatory and auth.check_secret_token(i.email, i.token)):
         msg = "Invalid token or there is no signature for this petition with this email."
         msg_type = 'error'
     else:
         msg = render_plain.confirm_unsign(pid, user.id)
         msg_type = ''
         
     helpers.set_msg(msg, msg_type)
     raise web.seeother('/%s' % pid)
예제 #24
0
def create_petition(i, email, wyrform):
    tocongress = i.get('tocongress', 'off') == 'on'
    i.pid = i.pid.replace(' ', '_')
    u = helpers.get_user_by_email(email)
    try:
        db.insert('petition', seqname=False, id=i.pid, title=i.ptitle, description=i.msg,
                owner_id=u.id, to_congress=tocongress)
    except:
        return
    signid = save_signature(i, i.pid, u.id, tocongress)            

    if tocongress and captcha_to_be_filled(i): wyrform.fill(signid=signid)
    if tocongress: send_to_congress(i, wyrform, signid)

    msg = """Congratulations, you've created your petition.
             Now sign and share it with all your friends."""
    helpers.set_msg(msg)
예제 #25
0
    def GET_unsign(self, pid):
        i = web.input()
        user = helpers.get_user_by_email(i.email)

        if user:
            where = "petition_id=$pid and user_id=$user.id and deleted is null"
            signatory = db.select("signatory", where=where, vars=locals())

        valid_token = auth.check_secret_token(i.get("email", ""), i.get("token", "@"))
        if not (user and signatory and valid_token):
            msg = "Invalid token or there is no signature for this petition with this email."
            msg_type = "error"
        else:
            msg = str(render_plain.confirm_unsign(pid, user.id))
            msg_type = ""

        helpers.set_msg(msg, msg_type)
        raise web.seeother("/%s" % pid)
예제 #26
0
    def GET_unsign(self, pid):
        i = web.input()
        user = helpers.get_user_by_email(i.email)

        if user:
            where = 'petition_id=$pid and user_id=$user.id and deleted is null'
            signatory = db.select('signatory', where=where, vars=locals())

        valid_token = auth.check_secret_token(i.get('email', ''),
                                              i.get('token', '@'))
        if not (user and signatory and valid_token):
            msg = "Invalid token or there is no signature for this petition with this email."
            msg_type = 'error'
        else:
            msg = str(render_plain.confirm_unsign(pid, user.id))
            msg_type = ''

        helpers.set_msg(msg, msg_type)
        raise web.seeother('/%s' % pid)
예제 #27
0
def save_signature(forminput, pid):        
    try:
        user = db.select('users', where='email=$forminput.email', vars=locals())[0]
    except:
        user_id = db.insert('users', name=forminput.name, email=forminput.email)
    else:
        user_id = user.id
        if user.name != forminput.name:
            db.update('users', where='id=$user_id', name=forminput.name, vars=locals())    
        
    user = web.storage(id=user_id, name=forminput.name, email=forminput.email)
    signed = db.select('signatory', where='petition_id=$pid AND user_id=$user.id', vars=locals())
    if not signed:
        signature = dict(petition_id=pid, user_id=user_id, 
                        share_with=forminput.share_with, comment=forminput.comment)
        db.insert('signatory', seqname=False, **signature)
        helpers.set_msg('Your signature has been taken for this petition.')
        helpers.unverified_login(user.email)
    return user    
예제 #28
0
 def GET(self):
     i = web.input()
     query = urllib.urlencode(dict(url=i.get('url'), title=i.get('title')))
     authToken = i.get('token')
     if not authToken:
         raise web.seeother('/share?%s' % query)
     email = i.get('email')
     emailq = urllib2.quote(email, '')
     url = ("http://www.google.com/m8/feeds/contacts/%s/full?max-results=999" % emailq)
     headers = { 'Authorization' : 'AuthSub token="%s"' % authToken.strip() }
     request = urllib2.Request(url, None, headers)
     try:
         response = urllib2.urlopen(request)
     except:
         helpers.set_msg('Authorization Failed.')
     else:        
         contacts = self.get_contacts(response)
         save_contacts(email, contacts, provider='GOOGLE')
     raise web.seeother('/share?%s' % query)
예제 #29
0
 def POST(self):
     i = web.input()
     emailform, loadcontactsform = forms.emailform(
     ), forms.loadcontactsform()
     if emailform.validates(i):
         url, msg, subject = i.url, i.body, i.subject
         emails = [e.strip() for e in i.emails.strip(', ').split(',')]
         u = helpers.get_user_by_email(helpers.get_loggedin_email()
                                       or helpers.get_unverified_email())
         from_address = u and "%s %s <%s>" % (
             u.fname, u.lname, u.email) or config.from_address
         for email in emails:
             web.sendmail(from_address, email, subject, msg)
         page_or_petition = url.startswith('/c/') and 'petition' or 'page'
         helpers.set_msg('Thanks for sharing this %s with your friends!' %
                         page_or_petition)
         raise web.seeother(url)
     else:
         return self.GET(emailform=emailform,
                         loadcontactsform=loadcontactsform)
예제 #30
0
 def GET_edit(self, pid):
     user_email = helpers.get_loggedin_email()
     if is_author(user_email, pid):
         p = get_petition_by_id(pid)
         u = helpers.get_user_by_email(user_email)
         pf = forms.petitionform()
         pf.fill(
             userid=u.id, email=user_email, pid=p.id, ptitle=p.title, msg=p.description, tocongress=p.to_congress
         )
         wf = forms.wyrform()
         fill_user_details(wf)
         isdraft = is_draft(p)
         return render.petitionform(pf, wf, is_new=False, is_draft=isdraft)
     elif user_email:
         msg = "You don't have permissions to edit this petition."
     else:
         login_link = '<a href="/u/login">Login</a>'
         msg = "Only author of this petition can edit it. %s if you are." % login_link
     helpers.set_msg(msg)
     raise web.seeother("/%s" % pid)
예제 #31
0
 def GET(self):
     i = web.input()
     query = urllib.urlencode(dict(url=i.get('url'), title=i.get('title')))
     authToken = i.get('token')
     if not authToken:
         raise web.seeother('/share?%s' % query)
     email = i.get('email')
     emailq = urllib2.quote(email, '')
     url = (
         "http://www.google.com/m8/feeds/contacts/%s/full?max-results=999" %
         emailq)
     headers = {'Authorization': 'AuthSub token="%s"' % authToken.strip()}
     request = urllib2.Request(url, None, headers)
     try:
         response = urllib2.urlopen(request)
     except:
         helpers.set_msg('Authorization Failed.')
     else:
         contacts = self.get_contacts(response)
         save_contacts(email, contacts, provider='GOOGLE')
     raise web.seeother('/share?%s' % query)
예제 #32
0
def save_signature(i, pid, uid, tocongress=False):
    has_captcha = tocongress and captcha_to_be_filled(i)
    msg_status = has_captcha and 'T' #mark it as temporary
    msg_status = msg_status or (tocongress and 'D') or 'N' # D=sending due; N=not for congress  

    where = 'petition_id=$pid AND user_id=$uid'
    signed = db.select('signatory', where=where, vars=locals())
    share_with = (i.get('share_with', 'off') == 'on' and 'N') or 'A'
    if not signed:
        referrer = get_referrer(pid, uid)
        signid = db.insert('signatory', 
                user_id=uid, share_with=share_with,
                petition_id=pid, comment=i.get('comment'),
                sent_to_congress=msg_status, referrer=referrer)
        update_user_details(i)
        helpers.set_msg("Thanks for your signing! Why don't you tell your friends about it now?")
        return signid 
    else:
        db.update('signatory', where='user_id=$uid and petition_id=$pid', 
                    comment=i.get('comment'), deleted=None, vars=locals())
        if not signed[0].sent_to_congress == 'T':
            helpers.set_msg("You've signature has been changed. Why don't you tell your friends about it now?")
예제 #33
0
    def POST(self):
        i = web.input()
        appdata = i.get('appdata', '||')
        email, share_url, title = appdata.split('|')
        if i.get('ResponseCode', '') == 'RequestApproved':
            consent = self.get_consent(i.ConsentToken)
            lid = consent.get('lid')
            delegatedToken = urllib.unquote(consent.get('delt'))
            url = 'https://livecontacts.services.live.com'
            url += '/users/@L@' + lid + '/rest/LiveContacts/Contacts'
            request = urllib2.Request(url)
            request.add_header('Content-Type', 'application/xml; charset=utf-8')
            request.add_header('Authorization', 'DelegatedToken dt="%s"' % delegatedToken)
            try:
                response = urllib2.urlopen(request)
            except:
                helpers.set_msg('Authorization Failed.')
            else:        
                contacts = self.get_contacts(response)
                save_contacts(email, contacts, provider='MICROSOFT')

        query = urllib.urlencode(dict(url=share_url, title=title))
        raise web.seeother('/share?%s' % query)
예제 #34
0
 def GET_edit(self, pid):
     user_email = helpers.get_loggedin_email()
     if is_author(user_email, pid):
         p = get_petition_by_id(pid)
         u = helpers.get_user_by_email(user_email)
         pf = forms.petitionform()
         pf.fill(userid=u.id,
                 email=user_email,
                 pid=p.id,
                 ptitle=p.title,
                 msg=p.description,
                 tocongress=p.to_congress)
         wf = forms.wyrform()
         fill_user_details(wf)
         isdraft = is_draft(p)
         return render.petitionform(pf, wf, is_new=False, is_draft=isdraft)
     elif user_email:
         msg = "You don't have permissions to edit this petition."
     else:
         login_link = '<a href="/u/login">Login</a>'
         msg = 'Only author of this petition can edit it. %s if you are.' % login_link
     helpers.set_msg(msg)
     raise web.seeother('/%s' % pid)
예제 #35
0
def create_petition(i, email):
    tocongress = i.get('tocongress', 'off') == 'on'
    i.pid = i.pid.replace(' ', '-')
    u = helpers.get_user_by_email(email)
    is_draft = 'save' in i
    published = None if is_draft else datetime.now()
    try:
        db.insert('petition',
                  seqname=False,
                  id=i.pid,
                  title=i.ptitle,
                  created=datetime.now(),
                  published=published,
                  description=i.msg,
                  owner_id=u.id,
                  to_congress=tocongress)
    except:
        return

    if is_draft:
        msg = """Petition saved for publishing later."""
        helpers.set_msg(msg)
    else:
        create_first_signature(i, u.email)
예제 #36
0
def save_password(forminput):
    password = auth.encrypt_password(forminput.password)
    db.update('users', where='id=$forminput.user_id', password=password, vars=locals())
    helpers.set_msg('Password stored')
예제 #37
0
 def POST_delete(self, pid):
     now = datetime.now()
     title = db.select("petition", what="title", where="id=$pid", vars=locals())[0].title
     db.update("petition", where="id=$pid", deleted=now, vars=locals())
     helpers.set_msg('Petition "%s" deleted' % (title))
     raise web.seeother("/")
예제 #38
0
 def POST_delete(self, pid):
     now = datetime.now()
     title = db.select('petition', what='title', where='id=$pid', vars=locals())[0].title
     db.update('petition', where='id=$pid', deleted=now, vars=locals())
     helpers.set_msg('Petition "%s" deleted' % (title))
     raise web.seeother('/')