Commit fbc06a5f authored by Jérome Perrin's avatar Jérome Perrin

ERP5: implement Telephone.asURL for non-detailed coordinates

/reviewed-on https://lab.nexedi.com/nexedi/erp5-capago/merge_requests/26
parent 2e42d1d0
......@@ -356,6 +356,11 @@ class Telephone(Coordinate):
"""Returns a text representation of the Url if defined
or None else.
"""
if not self.isDetailed():
coordinate_text = self.getCoordinateText()
if coordinate_text:
return 'tel:%s' % coordinate_text.replace(' ', '')
telephone_country = self.getTelephoneCountry()
if telephone_country is not None:
url_string = '+%s' % telephone_country
......
......@@ -333,10 +333,21 @@ class TestERP5Coordinate(ERP5TypeTestCase):
tel.setTelephoneNumber(123456789)
self.assertEqual('tel:+33123456789', tel.asURL())
tel.setTelephoneCountry(None)
tel = pers.newContent(portal_type='Telephone')
tel.setTelephoneNumber(123456789)
self.assertEqual('tel:0123456789', tel.asURL())
tel = pers.newContent(portal_type='Telephone')
tel.setCoordinateText('+33123456789')
self.assertEqual('tel:+33123456789', tel.asURL())
# from rfc3966
# """ "tel" URIs MUST NOT use spaces in visual separators to avoid
# excessive escaping."""
tel = pers.newContent(portal_type='Telephone')
tel.setCoordinateText('01 23 45 67 89')
self.assertEqual('tel:0123456789', tel.asURL())
def test_EmptyTelephoneAsText(self):
# asText method returns an empty string for empty telephones
pers = self.getPersonModule().newContent(portal_type='Person')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment