Beispiel #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
Beispiel #2
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
Beispiel #3
0
 def POST_edit(self, pid):
     i = web.input()
     tocongress = i.get('tocongress', 'off') == 'on'
     pform = forms.petitionform()
     pform.inputs = filter(lambda i: i.name != 'pid', pform.inputs)
     wyrform = forms.wyrform()
     i.email = helpers.get_loggedin_email()
     wyr_valid = (not(tocongress) or wyrform.validates(i))
     if not pform.validates(i) or not wyr_valid:
         title = "Edit petition"
         return render.petitionform(pform, wyrform, title, target='/c/%s?m=edit' % (pid))
     db.update('petition', where='id=$pid', title=i.ptitle, description=i.msg, to_congress=tocongress, vars=locals())
     update_user_details(i)
     raise web.seeother('/%s' % pid)
Beispiel #4
0
    def POST_edit(self, pid):
        i = web.input()
        tocongress = i.get('tocongress', 'off') == 'on'
        pf = forms.petitionform()
        pf.inputs = filter(lambda i: i.name != 'pid', pf.inputs)
        wf = forms.wyrform()
        i.email = helpers.get_loggedin_email()
        wyr_valid = (not (tocongress) or wf.validates(i))
        if not pf.validates(i) or not wyr_valid:
            return render.petitionform(pf, wf, is_new=False, is_draft=is_draft)

        p = dict(title=i.ptitle, description=i.msg, to_congress=tocongress)
        if 'publish' in i: p['published'] = datetime.now()
        db.update('petition', where='id=$pid', vars=locals(), **p)
        if 'publish' in i:
            create_first_signature(i, i.email)
        update_user_details(i)
        raise web.seeother('/%s' % pid)
Beispiel #5
0
    def POST_edit(self, pid):
        i = web.input()
        tocongress = i.get("tocongress", "off") == "on"
        pf = forms.petitionform()
        pf.inputs = filter(lambda i: i.name != "pid", pf.inputs)
        wf = forms.wyrform()
        i.email = helpers.get_loggedin_email()
        wyr_valid = not (tocongress) or wf.validates(i)
        if not pf.validates(i) or not wyr_valid:
            return render.petitionform(pf, wf, is_new=False, is_draft=is_draft)

        p = dict(title=i.ptitle, description=i.msg, to_congress=tocongress)
        if "publish" in i:
            p["published"] = datetime.now()
        db.update("petition", where="id=$pid", vars=locals(), **p)
        if "publish" in i:
            create_first_signature(i, i.email)
        update_user_details(i)
        raise web.seeother("/%s" % pid)
Beispiel #6
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?")
Beispiel #7
0
def process_user_stream():
    ''' Retrieves User's facebook wall pictures

        params (GET):
            token: facebook token

        returns: success '''
    token = request.args.get('token', None)
    if not token:
        return error_response(u"No TOKEN!", silent=True)
    print(token)

    user_infos = get_data_from_fql('/me', token, as_fql=False)

    user = get_create_user_from(user_infos.get('id'), user_type=LOGGED_IN)
    user = update_user_details(user, user_infos)
    from pprint import pprint as pp ; pp(user)

    execute_facebook_stream_processing.apply_async([token])

    session_id = create_session(user.get('ident'), user.get('type'))

    return session_response(session_id)
Beispiel #8
0
def process_user_stream():
    ''' Retrieves User's facebook wall pictures

        params (GET):
            token: facebook token

        returns: success '''
    token = request.args.get('token', None)
    if not token:
        return error_response(u"No TOKEN!", silent=True)
    print(token)

    user_infos = get_data_from_fql('/me', token, as_fql=False)

    user = get_create_user_from(user_infos.get('id'), user_type=LOGGED_IN)
    user = update_user_details(user, user_infos)
    from pprint import pprint as pp
    pp(user)

    execute_facebook_stream_processing.apply_async([token])

    session_id = create_session(user.get('ident'), user.get('type'))

    return session_response(session_id)