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): ...@@ -87,12 +87,11 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
Returns the title if it exists or a combination of Returns the title if it exists or a combination of
first name, middle name and last name first name, middle name and last name
""" """
if not self.title: title = ' '.join([x for x in (self.getFirstName(),
title = ' '.join([x for x in (self.getFirstName(), self.getMiddleName(),
self.getMiddleName(), self.getLastName()) if x])
self.getLastName()) if x]) if title:
if title: return title
return title
return super(Person, self).getTitle(**kw) return super(Person, self).getTitle(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
...@@ -102,12 +101,11 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin): ...@@ -102,12 +101,11 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
Returns the title if it exists or a combination of Returns the title if it exists or a combination of
first name, middle name and last name first name, middle name and last name
""" """
if not self.title: title = ' '.join([x for x in (self.getTranslatedFirstName(**kw),
title = ' '.join([x for x in (self.getTranslatedFirstName(**kw), self.getTranslatedMiddleName(**kw),
self.getTranslatedMiddleName(**kw), self.getTranslatedLastName(**kw)) if x])
self.getTranslatedLastName(**kw)) if x]) if title:
if title: return title
return title
return super(Person, self).getTranslatedTitle(**kw) return super(Person, self).getTranslatedTitle(**kw)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
......
...@@ -174,9 +174,9 @@ class TestPerson(ERP5TypeTestCase): ...@@ -174,9 +174,9 @@ class TestPerson(ERP5TypeTestCase):
p.edit( first_name='first', p.edit( first_name='first',
last_name='last', last_name='last',
title='title' ) title='title' )
self.assertEqual('title', p.getTitle()) self.assertEqual('first last', p.getTitle())
p.edit(middle_name='middle') p.edit(middle_name='middle')
self.assertEqual('title', p.getTitle()) self.assertEqual('first middle last', p.getTitle())
def testGetTitleOrId(self): def testGetTitleOrId(self):
p = self._makeOne(id='person') p = self._makeOne(id='person')
......
  • @romain @kazuhiko This change seem to introduce a test failure https://nexedi.erp5.net/test_result_module/20160530-164D738F/224

    I feel we are lacking a test like this one:

      def test_PersonGetTitleDefined(self):
        p = self._makeOne(title="title")
        self.assertEqual("title", p.getTitle())

    but please confirm this is expected behavior.

  • For reference, the test failure from previous message was addressed as 80c30ea0 and the test_PersonGetTitleDefined was added as 80c30ea0

    This change which gives priority to First Name and Last Name even when Title is set solves https://nexedi.erp5.net/bug_module/20160115-CD8FF4

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