[Erp5-report] r25305 - in /erp5/trunk/products/ERP5: Document/ PropertySheet/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Jan 26 11:25:37 CET 2009
Author: aurel
Date: Mon Jan 26 11:25:36 2009
New Revision: 25305
URL: http://svn.erp5.org?rev=25305&view=rev
Log:
defined the city area in telephone numbers
add regexp for it
modify unit test to take into account this new property
add new preference property to defined preferred city area
Modified:
erp5/trunk/products/ERP5/Document/Telephone.py
erp5/trunk/products/ERP5/PropertySheet/Telephone.py
erp5/trunk/products/ERP5/PropertySheet/TelephonePreference.py
erp5/trunk/products/ERP5/tests/testERP5Base.py
Modified: erp5/trunk/products/ERP5/Document/Telephone.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Telephone.py?rev=25305&r1=25304&r2=25305&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Telephone.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Telephone.py [utf8] Mon Jan 26 11:25:36 2009
@@ -32,7 +32,7 @@
from Products.ERP5Type.Base import Base
from Products.ERP5.Document.Coordinate import Coordinate
-
+from zLOG import LOG
import re
class Telephone(Coordinate, Base):
@@ -71,12 +71,19 @@
# The list is a priority list,
# be carefull to add a new regex.
regex_list = [
+ # Country, Area, City, Number, Extension*
+ "\+(?P<country>[\d ]+)(?P<toto>\(0\)|\ |\-)(?P<area>\d+)(\-|\ )(?P<city>\d+)(\-|\ )(?P<number>[\d\ \-]*)(?:\/)?(?P<ext>\d+|)",
+
+ # Area, City, Number, Extension*
+ "^(\(0\)|0)?(?P<area>\d+)(\-|\ |\/)(?P<city>\d+)(\-|\ )(?P<number>[\d\ \-]*)(?:\/)?(?P<ext>\d+|)",
+
# Country, Area, Number, Extension*
# +11(0)1-11111111/111 or +11(0)1-11111111/ or +11(0)1-11111111
# +11(0)1-1111-1111/111 or +11(0)1-1111-1111/ or +11(0)1-1111-1111
# + 11 (0)1-11 11 01 01/111 or + 11 (0)1-11 11 01 01/ or + 11 (0)1-11 11 01 01
# +11 (0)11 1011 1100/111 or +11 (0)11 1011 1100/ or +11 (0)11 1011 1100
"\+(?P<country>[\d\ ]*)\(0\)(?P<area>\d+)(\-|\ )(?P<number>[\d\ \-]*)(?:\/)?(?P<ext>\d+|)",
+
# Country, Area, Number, Extension*
# +11-1-11111111/111 or +11-1-11111111/ or +11-1-11111111
@@ -215,7 +222,7 @@
# (11-1) 1.111.111/111 or (11-1) 1.111.111/ or (11-1) 1.111.111
"\((\+|)(?P<country>\d+)\-(?P<area>\d+)\)(\ |\-|)(?P<number>[\d\ \-\.]*)(?:\/)?(?P<ext>\d+|)",
- # Country, area, number and extersion*
+ # Country, area, number and extension*
# + 111-11-1110111/111 or + 111-11-1110111/ or + 111-11-1110111
# +111-11-1110111/111 or +111-11-1110111/ or +111-11-1110111
# +111/1/1111 1100/111 or +111/1/1111 1100/ or +111/1/1111 1100
@@ -263,14 +270,15 @@
country = number_dict.get('country','')
area = number_dict.get('area','')
+ city = number_dict.get('city','')
number = number_dict.get('number','')
extension = number_dict.get('ext','')
-
if ((country in ['', None]) and \
(area in ['', None]) and \
+ (city in ['', None]) and \
(number in ['', None]) and \
(extension in ['', None])):
- country = area = number = extension = ''
+ country = area = city = number = extension = ''
else:
# Trying to get the country and area from dict,
# but if it fails must be get from preference
@@ -279,9 +287,12 @@
country = preference_tool.getPreferredTelephoneDefaultCountryNumber('')
if area in ['', None]:
area = preference_tool.getPreferredTelephoneDefaultAreaNumber('')
+ if city in ['', None]:
+ city = preference_tool.getPreferredTelephoneDefaultCityNumber('')
country = country.strip()
area = area.strip()
+ city = city.strip()
number = number.strip()
extension = extension.strip()
@@ -293,6 +304,7 @@
self.edit(telephone_country = country,
telephone_area = area,
+ telephone_city = city,
telephone_number = number,
telephone_extension = extension)
@@ -310,6 +322,7 @@
country = self.getTelephoneCountry('')
area = self.getTelephoneArea('')
+ city = self.getTelephoneCity('')
number = self.getTelephoneNumber('')
extension = self.getTelephoneExtension('')
@@ -317,6 +330,7 @@
# the method should to return blank.
if ((country == '') and \
(area == '') and \
+ (city == '') and \
(number == '') and \
(extension == '')):
return ''
@@ -326,6 +340,10 @@
if notation not in [None, '']:
notation = notation.replace('<country>',country)
notation = notation.replace('<area>',area)
+ if city == "":
+ notation = notation.replace('<city>-', '')
+ else:
+ notation = notation.replace('<city>',city)
notation = notation.replace('<number>',number)
notation = notation.replace('<ext>',extension)
@@ -349,6 +367,10 @@
telephone_area = self.getTelephoneArea()
if telephone_area is not None:
url_string += telephone_area
+
+ telephone_city = self.getTelephoneCity()
+ if telephone_city is not None:
+ url_string += telephone_city
telephone_number = self.getTelephoneNumber()
if telephone_number is not None:
@@ -373,8 +395,8 @@
Returns the notation that will be used by asText method.
"""
# The notation can be changed.
- # But needs to have <country>, <area>, <number> and <ext>
- return "+<country>(0)<area>-<number>/<ext>"
+ # But needs to have <country>, <area>, <city>, <number> and <ext>
+ return "+<country>(0)<area>-<city>-<number>/<ext>"
def _getRegexList(self):
"""
Modified: erp5/trunk/products/ERP5/PropertySheet/Telephone.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/PropertySheet/Telephone.py?rev=25305&r1=25304&r2=25305&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/PropertySheet/Telephone.py [utf8] (original)
+++ erp5/trunk/products/ERP5/PropertySheet/Telephone.py [utf8] Mon Jan 26 11:25:36 2009
@@ -42,6 +42,10 @@
'description' : 'Area indicative number',
'type' : 'string',
'mode' : 'w' },
+ { 'id' : 'telephone_city',
+ 'description' : 'City indicative number',
+ 'type' : 'string',
+ 'mode' : 'w' },
{ 'id' : 'telephone_number',
'description' : 'Telephone number minus indicatives',
'type' : 'string',
Modified: erp5/trunk/products/ERP5/PropertySheet/TelephonePreference.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/PropertySheet/TelephonePreference.py?rev=25305&r1=25304&r2=25305&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/PropertySheet/TelephonePreference.py [utf8] (original)
+++ erp5/trunk/products/ERP5/PropertySheet/TelephonePreference.py [utf8] Mon Jan 26 11:25:36 2009
@@ -48,6 +48,13 @@
'mode' : 'w',
'default' : '',
},
+ { 'id' : 'preferred_telephone_default_city_number',
+ 'description' : 'The default city number.',
+ 'type' : 'string',
+ 'preference' : 1,
+ 'mode' : 'w',
+ 'default' : '',
+ },
{ 'id' : 'preferred_telephone_default_region',
'description' : 'The default region.',
'type' : 'string',
Modified: erp5/trunk/products/ERP5/tests/testERP5Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testERP5Base.py?rev=25305&r1=25304&r2=25305&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testERP5Base.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testERP5Base.py [utf8] Mon Jan 26 11:25:36 2009
@@ -914,7 +914,7 @@
['+11(0)-1111111/111', '+11(0)-1111111/111'],
['+11(0)-1111111/', '+11(0)-1111111'],
['+11(0)-1111111', '+11(0)-1111111'],
- ['+11 111 1111 1111/111', '+11(0)111-11111111/111'],
+ ['+11 111 1111 1111/111', '+11(0)111-1111-1111/111'],
['+11(1)11111111/', '+11(0)1-11111111'],
['+11(1)11111111', '+11(0)1-11111111'],
['+11()11111111/111', '+11(0)-11111111/111'],
@@ -948,29 +948,29 @@
['(11)-11111111', '+(0)11-11111111'],
['+11 1 011111111/1', '+11(0)1-011111111/1'],
['+11 1 011111111', '+11(0)1-011111111'],
- ['+11 111 1111 1111/', '+11(0)111-11111111'],
- ['1-11 01 11 11/111', '+(0)1-11011111/111'],
- ['1-11 01 11 11/', '+(0)1-11011111'],
- ['1-11 01 11 11', '+(0)1-11011111'],
- ['11 01 11 11/111', '+(0)-11011111/111'],
- ['11 01 11 11/', '+(0)-11011111'],
- ['11 01 11 11', '+(0)-11011111'],
- ['111 11 11/111', '+(0)-1111111/111'],
- ['111 11 11/', '+(0)-1111111'],
- ['111 11 11', '+(0)-1111111'],
- ['111-11 11/111', '+(0)111-1111/111'],
- ['111-11 11/', '+(0)111-1111'],
- ['111-11 11', '+(0)111-1111'],
+ ['+11 111 1111 1111/', '+11(0)111-1111-1111'],
+ ['1-11 01 11 11/111', '+(0)1-11-011111/111'],
+ ['1-11 01 11 11/', '+(0)1-11-011111'],
+ ['1-11 01 11 11', '+(0)1-11-011111'],
+ ['11 01 11 11/111', '+(0)11-01-1111/111'],
+ ['11 01 11 11/', '+(0)11-01-1111'],
+ ['11 01 11 11', '+(0)11-01-1111'],
+ ['111 11 11/111', '+(0)111-11-11/111'],
+ ['111 11 11/', '+(0)111-11-11'],
+ ['111 11 11', '+(0)111-11-11'],
+ ['111-11 11/111', '+(0)111-11-11/111'],
+ ['111-11 11/', '+(0)111-11-11'],
+ ['111-11 11', '+(0)111-11-11'],
['1111111/11', '+(0)-1111111/11'],
- ['011-111-1111/111', '+(0)11-1111111/111'],
- ['011-111-1111/', '+(0)11-1111111'],
- ['011-111-1111', '+(0)11-1111111'],
+ ['011-111-1111/111', '+(0)11-111-1111/111'],
+ ['011-111-1111/', '+(0)11-111-1111'],
+ ['011-111-1111', '+(0)11-111-1111'],
['011(111)1111/111', '+(0)11-1111111/111'],
['011(111)1111/', '+(0)11-1111111'],
['011(111)1111', '+(0)11-1111111'],
- ['111/111-1111/111', '+(0)111-1111111/111'],
- ['111/111-1111/', '+(0)111-1111111'],
- ['111/111-1111', '+(0)111-1111111'],
+ ['111/111-1111/111', '+(0)111-111-1111/111'],
+ ['111/111-1111/', '+(0)111-111-1111'],
+ ['111/111-1111', '+(0)111-111-1111'],
['+11 111111111/111', '+11(0)-111111111/111'],
['+11 111111111/', '+11(0)-111111111'],
['+11 111111111', '+11(0)-111111111'],
@@ -983,12 +983,12 @@
['111.111.1111/111', '+(0)111-1111111/111'],
['111.111.1111/', '+(0)111-1111111'],
['111.111.1111', '+(0)111-1111111'],
- ['+ 11 (0)1-11 11 01 01/111', '+11(0)1-11110101/111'],
- ['+ 11 (0)1-11 11 01 01/', '+11(0)1-11110101'],
- ['+ 11 (0)1-11 11 01 01', '+11(0)1-11110101'],
- ['+11-1 11 11 01 11/111', '+11(0)1-11110111/111'],
- ['+11-1 11 11 01 11/', '+11(0)1-11110111'],
- ['+11-1 11 11 01 11', '+11(0)1-11110111'],
+ ['+ 11 (0)1-11 11 01 01/111', '+11(0)1-11-110101/111'],
+ ['+ 11 (0)1-11 11 01 01/', '+11(0)1-11-110101'],
+ ['+ 11 (0)1-11 11 01 01', '+11(0)1-11-110101'],
+ ['+11-1 11 11 01 11/111', '+11(0)1-11-110111/111'],
+ ['+11-1 11 11 01 11/', '+11(0)1-11-110111'],
+ ['+11-1 11 11 01 11', '+11(0)1-11-110111'],
['+111 (0) 1 111 11011/111', '+111(0)1-11111011/111'],
['+111 (0) 1 111 11011/', '+111(0)1-11111011'],
['+111 (0) 1 111 11011', '+111(0)1-11111011'],
@@ -1001,12 +1001,12 @@
['+111 101011111/111', '+111(0)-101011111/111'],
['+111 101011111/', '+111(0)-101011111'],
['+111 101011111', '+111(0)-101011111'],
- ['+11 (0)11 1011 1100/111', '+11(0)11-10111100/111'],
- ['+11 (0)11 1011 1100/', '+11(0)11-10111100'],
- ['+11 (0)11 1011 1100', '+11(0)11-10111100'],
- ['+11 (0)10 1101 1111/111', '+11(0)10-11011111/111'],
- ['+11 (0)10 1101 1111/', '+11(0)10-11011111'],
- ['+11 (0)10 1101 1111', '+11(0)10-11011111'],
+ ['+11 (0)11 1011 1100/111', '+11(0)11-1011-1100/111'],
+ ['+11 (0)11 1011 1100/', '+11(0)11-1011-1100'],
+ ['+11 (0)11 1011 1100', '+11(0)11-1011-1100'],
+ ['+11 (0)10 1101 1111/111', '+11(0)10-1101-1111/111'],
+ ['+11 (0)10 1101 1111/', '+11(0)10-1101-1111'],
+ ['+11 (0)10 1101 1111', '+11(0)10-1101-1111'],
['(111 11) 111111/111', '+111(0)11-111111/111'],
['(111 11) 111111/', '+111(0)11-111111'],
['(111 11) 111111', '+111(0)11-111111'],
@@ -1058,9 +1058,9 @@
['+10 (111) 110 11 11/111', '+10(0)111-1101111/111'],
['+10 (111) 110 11 11/', '+10(0)111-1101111'],
['+10 (111) 110 11 11', '+10(0)111-1101111'],
- ['+ 111 1 1101 101/111', '+111(0)1-1101101/111'],
- ['+ 111 1 1101 101/', '+111(0)1-1101101'],
- ['+ 111 1 1101 101', '+111(0)1-1101101'],
+ ['+ 111 1 1101 101/111', '+111(0)1-1101-101/111'],
+ ['+ 111 1 1101 101/', '+111(0)1-1101-101'],
+ ['+ 111 1 1101 101', '+111(0)1-1101-101'],
['+11 1111-1111/111', '+11(0)-11111111/111'],
['+11 1111-1111/', '+11(0)-11111111'],
['+11 1111-1111', '+11(0)-11111111'],
@@ -1076,11 +1076,12 @@
['+111/1/1111 1100/111', '+111(0)1-11111100/111'],
['+111/1/1111 1100/', '+111(0)1-11111100'],
['+111/1/1111 1100', '+111(0)1-11111100'],
- ['+11(0)11-1111-1111/111', '+11(0)11-11111111/111'],
+ ['+11(0)11-1111-1111/111', '+11(0)11-1111-1111/111'],
]
for i in input_list:
tel.fromText(coordinate_text=i[0])
+ print i
self.assertEquals(i[1],tel.asText())
def test_TelephoneWhenTheDefaultCountryAndAreaPreferenceIsBlank(self):
More information about the Erp5-report
mailing list