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)
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)
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)
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)
def POST(self): i = web.input() email = i.get('email') form = forms.loadcontactsform() if form.validates(i): session.email = email session.pid = i.pid if i.provider == 'Yahoo': ylogin_url = yahooLoginURL(email, '/WSLogin/V1/wslogin') raise web.seeother(ylogin_url) elif i.provider == 'Google': glogin_url = gmailLoginURL(email) raise web.seeother(glogin_url) else: import petition share_obj = petition.share() return share_obj.GET(form)
def POST(self): i = web.input() email, url, title = i.get('email', ''), i.get('url', '/'), i.get('title', '') form = forms.loadcontactsform() if form.validates(i): if i.provider == 'yahoo': ylogin_url = yahooLoginURL(email, '/WSLogin/V1/wslogin', share_url=url, title=title) raise web.seeother(ylogin_url) elif i.provider == 'google': glogin_url = gmailLoginURL(email, url, title) raise web.seeother(glogin_url) elif i.provider == 'msn': mlogin_url = msnLoginURL(email, url, title) raise web.seeother(mlogin_url) else: import petition share_obj = petition.share() emailform = forms.emailform() return share_obj.GET(emailform, form)
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)