Commit 149fdd1d authored by Jérome Perrin's avatar Jérome Perrin

credential: stop using deprecated property for email

In 44e0b22f (Move to new API, detailed properties take precedence,
2011-09-09) we introduce a new data model for coordinates, in the case
of emails, we have "url_string" fro the "detailed" form and
"coordinate_text", for the "store what user entered" form.

In some places of erp5_credential, we use setDefaultEmailText, which
calls Coordinate.setText which uses the deprecated Coordinate.fromText,
which sets the same value for "url_string" and "coordinate_text", which
seems a questionable behavior, because the data is saved twice and
some code might be using the wrong property.

This changes every usage to the new coordinate_text property
parent 5eeff828
......@@ -30,7 +30,7 @@ person_mapping = (
('gender', 'gender'),
('default_telephone_text', 'default_telephone_text'),
('default_mobile_telephone_text', 'default_mobile_telephone_text'),
('default_email_text', 'default_email_text'),
('default_email_coordinate_text', 'default_email_coordinate_text'),
('date_of_birth', 'start_date'),
('nationality', 'nationality'),
('skill_list', 'default_career_skill_list'),
......
......@@ -5,7 +5,7 @@ organisation = context.getDestinationDecisionValue(portal_type="Organisation")
#Mapping
organisation_mapping = (
# (subscription, organisation)
('default_email_text', 'default_email_text'),
('default_email_coordinate_text', 'default_email_coordinate_text'),
('default_telephone_text', 'default_telephone_text'),
('default_fax_text', 'default_fax_text'),
('default_address_street_address', 'default_address_street_address'),
......
......@@ -13,7 +13,7 @@ person_mapping = (
('date_of_birth', 'birthday'),
('nationality', 'nationality'),
('language', 'language'),
('default_email_text', 'default_email_text'),
('default_email_coordinate_text', 'default_email_coordinate_text'),
('default_telephone_telephone_country', 'default_telephone_telephone_country'),
('default_telephone_text', 'default_telephone_text'),
('default_fax_text', 'default_fax_text'),
......
......@@ -33,7 +33,7 @@ if default_email_text is not None:
message = "We have sent you an email containing your username(s). Please check your inbox and your junk/spam mail for this email."
if web_site:
document_reference = web_site.getCredentialUsernameRecoveryMessageReference()
createCredentialRecovery(default_email_text=default_email_text,
createCredentialRecovery(default_email_coordinate_text=default_email_text,
destination_decision_value_list=person_list,
document_reference=document_reference,
language=portal.Localizer.get_selected_language())
......
......@@ -23,7 +23,7 @@ credential_request = module.newContent(
default_credential_question_question=default_credential_question_question,
default_credential_question_question_free_text=default_credential_question_question_free_text,
default_credential_question_answer=default_credential_question_answer,
default_email_text=default_email_text,
default_email_coordinate_text=default_email_text,
default_telephone_text=default_telephone_text,
default_mobile_telephone_text=default_mobile_telephone_text,
default_fax_text=default_fax_text,
......
......@@ -403,6 +403,8 @@ class TestERP5Credential(ERP5TypeTestCase):
person = person_result[0].getObject()
self.assertEqual(person.getTitle(), 'Homer Simpson')
self.assertEqual(person.getDefaultEmailText(), 'homer.simpson@fox.com')
# the obsolete email property is not used
self.assertFalse(person.hasDefaultEmailUrlString())
# check homie can log in the system
self._assertUserExists('homie', 'secret')
......@@ -429,7 +431,7 @@ class TestERP5Credential(ERP5TypeTestCase):
last_name='Simpsons', # add a 's' to the end of the last_name
reference='homie',
password='new_password',
default_email_text='homie.simpsons@fox.com',
default_email_coordinate_text='homie.simpsons@fox.com',
destination_decision=homie.getRelativeUrl())
credential_update.submit()
......@@ -456,6 +458,7 @@ class TestERP5Credential(ERP5TypeTestCase):
self.assertEqual(related_person.getLastName(), 'Simpsons')
self.assertEqual(related_person.getDefaultEmailText(),
'homie.simpsons@fox.com')
self.assertFalse(related_person.hasDefaultEmailUrlString())
def stepCreateSubscriptionRequestWithSecurityQuestionCategory(self, sequence=None,
sequence_list=None, **kw):
......@@ -544,7 +547,7 @@ class TestERP5Credential(ERP5TypeTestCase):
person = person_module.newContent(title='Barney',
reference='barney',
start_date=DateTime('1970/01/01'),
default_email_text='barney@duff.com')
default_email_coordinate_text='barney@duff.com')
# create an assignment
assignment = person.newContent(portal_type='Assignment',
function='member')
......@@ -862,6 +865,7 @@ class TestERP5Credential(ERP5TypeTestCase):
self.assertEqual("Homer", person.getFirstName())
self.assertEqual("Simpson", person.getLastName())
self.assertEqual("homer.simpson@fox.com", person.getDefaultEmailText())
self.assertFalse(person.hasDefaultEmailUrlString())
self.assertEqual(DateTime('1970/01/01'), person.getStartDate())
self.logout()
......@@ -878,6 +882,7 @@ class TestERP5Credential(ERP5TypeTestCase):
self.assertEqual("tom", person.getFirstName())
self.assertEqual("Simpson", person.getLastName())
self.assertEqual("tom@host.com", person.getDefaultEmailText())
self.assertFalse(person.hasDefaultEmailUrlString())
self.assertEqual(DateTime('1970/01/01'), person.getStartDate())
def stepCheckPersonWhenCredentialUpdateFail(self, sequence=None,
......@@ -1138,6 +1143,7 @@ class TestERP5Credential(ERP5TypeTestCase):
self.assertEqual(credential_request.getFirstName(), "Barney")
self.assertEqual(credential_request.getDefaultEmailText(),
"barney@duff.com")
self.assertFalse(credential_request.hasDefaultEmailUrlString())
self.assertEqual(credential_request.getRole(), "internal")
self.assertEqual(credential_request.getFunction(), "member")
......
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