def test_mail_to(self): self.assertEqual(u'<a href="mailto:[email protected]">[email protected]</a>', mail_to("*****@*****.**")) self.assertEqual( u'<a href="mailto:[email protected]">Justin Example</a>', mail_to("*****@*****.**", "Justin Example") ) self.assertEqual( u'<a class="admin" href="mailto:[email protected]">Justin Example</a>', mail_to("*****@*****.**", "Justin Example", class_="admin"), )
def test_mail_to_with_hex(self): self.assertEqual( u'<a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d">My email</a>', mail_to("*****@*****.**", "My email", encode="hex"), ) self.assertEqual( u'<a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d">me@domain.com</a>', mail_to("*****@*****.**", None, encode="hex"), )
def test_mail_to_with_replace_options(self): self.assertEqual( u'<a href="mailto:[email protected]">wolfgang(at)stufenlos(dot)net</a>', mail_to("*****@*****.**", None, replace_at="(at)", replace_dot="(dot)"), ) self.assertEqual( u'<a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d">me(at)domain.com</a>', mail_to("*****@*****.**", None, encode="hex", replace_at="(at)"), ) self.assertEqual( u'<a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d">My email</a>', mail_to("*****@*****.**", "My email", encode="hex", replace_at="(at)"), ) self.assertEqual( u'<a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d">me(at)domain(dot)com</a>', mail_to("*****@*****.**", None, encode="hex", replace_at="(at)", replace_dot="(dot)"), ) self.assertEqual( u"<script type=\"text/javascript\">\n//<![CDATA[\neval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))\n//]]>\n</script>", mail_to("*****@*****.**", "My email", encode="javascript", replace_at="(at)", replace_dot="(dot)"), )
def test_mail_to_with_options(self): self.assertEqual( u'<a href="mailto:[email protected]?cc=ccaddress%40example.com&bcc=bccaddress%40example.com&subject=This%20is%20an%20example%20email&body=This%20is%20the%20body%20of%20the%20message.">My email</a>', mail_to( "*****@*****.**", "My email", cc="*****@*****.**", bcc="*****@*****.**", subject="This is an example email", body="This is the body of the message.", ), )
def users(self): checkLogin() c.site = "User administration" c.name = session['project_id'] c.menu = genMenu(self) p = Project() p.load(c.name, getConfig()) c.header = ('Login', 'EMail', "Remove?") c.rows = [(x[0], mail_to(x[3]), link_to("Remove", \ url(controller="project", action='userRemove', id = x[0]), \ confirm="Are You sure?")) \ for x in p.getUsers()] c.style = "width: 70%; text-align: center;" c.content = render("/table.html") return render("/temp.html")
def usersRequests(self): checkLogin() c.site = "User requests" c.name = session['project_id'] c.menu = genMenu(self) p = Project() p.load(c.name, getConfig()) c.header = ('Login', 'EMail', 'Accept as member', "Decline") c.rows = [(x[0], mail_to(x[1]), link_to("Accept", \ url(controller="project", action='requestAccept', id = x[0])), \ link_to("Decline", \ url(controller="project", action='requestDecline', id = x[0]))) \ for x in p.getRequests()] c.style = "width: 70%; text-align: center;" c.content = render("/table.html") return render("/temp.html")
def link(self): return mail_to(self.email_address, self.display_name, subject=u'[SAUCE] ')
def test_mail_to_with_img(self): self.assertEqual( u'<a href="mailto:[email protected]"><img src="/feedback.png" /></a>', mail_to("*****@*****.**", HTML.literal('<img src="/feedback.png" />')), )
def test_mail_to_with_javascript(self): self.assertEqual( u"<script type=\"text/javascript\">\n//<![CDATA[\neval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))\n//]]>\n</script>", mail_to("*****@*****.**", "My email", encode="javascript"), )