Commit 9cc2191c authored by Romain Courteaud's avatar Romain Courteaud

fixup! fix middle name handling in Person.

Person.getTitle used to return first/last name properties when defined, as the title property was always dropped.

This fixes nexedi/erp5@2155dbf5
parent 316e1147
......@@ -87,12 +87,11 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
Returns the title if it exists or a combination of
first name, middle name and last name
"""
if not self.title:
title = ' '.join([x for x in (self.getFirstName(),
self.getMiddleName(),
self.getLastName()) if x])
if title:
return title
title = ' '.join([x for x in (self.getFirstName(),
self.getMiddleName(),
self.getLastName()) if x])
if title:
return title
return super(Person, self).getTitle(**kw)
security.declareProtected(Permissions.AccessContentsInformation,
......@@ -102,12 +101,11 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
Returns the title if it exists or a combination of
first name, middle name and last name
"""
if not self.title:
title = ' '.join([x for x in (self.getTranslatedFirstName(**kw),
self.getTranslatedMiddleName(**kw),
self.getTranslatedLastName(**kw)) if x])
if title:
return title
title = ' '.join([x for x in (self.getTranslatedFirstName(**kw),
self.getTranslatedMiddleName(**kw),
self.getTranslatedLastName(**kw)) if x])
if title:
return title
return super(Person, self).getTranslatedTitle(**kw)
security.declareProtected(Permissions.AccessContentsInformation,
......
......@@ -174,9 +174,9 @@ class TestPerson(ERP5TypeTestCase):
p.edit( first_name='first',
last_name='last',
title='title' )
self.assertEqual('title', p.getTitle())
self.assertEqual('first last', p.getTitle())
p.edit(middle_name='middle')
self.assertEqual('title', p.getTitle())
self.assertEqual('first middle last', p.getTitle())
def testGetTitleOrId(self):
p = self._makeOne(id='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