Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bryan Kaperick
erp5
Commits
2155dbf5
Commit
2155dbf5
authored
Feb 19, 2015
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix middle name handling in Person.
parent
bd01e897
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
41 deletions
+23
-41
product/ERP5/Document/Person.py
product/ERP5/Document/Person.py
+10
-40
product/ERP5/tests/testPerson.py
product/ERP5/tests/testPerson.py
+13
-1
No files found.
product/ERP5/Document/Person.py
View file @
2155dbf5
...
...
@@ -93,17 +93,12 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
def
getTitle
(
self
,
**
kw
):
"""
Returns the title if it exists or a combination of
first name and last name
first name
, middle name
and last name
"""
if
self
.
title
==
''
:
name_list
=
[]
if
self
.
getFirstName
()
not
in
(
None
,
''
):
name_list
.
append
(
self
.
getFirstName
())
if
self
.
getMiddleName
()
not
in
(
None
,
''
):
name_list
.
append
(
self
.
getMiddleName
())
if
self
.
getLastName
()
not
in
(
None
,
''
):
name_list
.
append
(
self
.
getLastName
())
return
' '
.
join
(
name_list
)
if
not
self
.
title
:
return
' '
.
join
([
x
for
x
in
(
self
.
getFirstName
(),
self
.
getMiddleName
(),
self
.
getLastName
())
if
x
])
else
:
return
self
.
title
...
...
@@ -112,17 +107,12 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
def
getTranslatedTitle
(
self
,
**
kw
):
"""
Returns the title if it exists or a combination of
first name and last name
first name
, middle name
and last name
"""
if
self
.
title
==
''
:
name_list
=
[]
if
self
.
getTranslatedFirstName
(
**
kw
)
not
in
(
None
,
''
):
name_list
.
append
(
self
.
getTranslatedFirstName
(
**
kw
))
if
self
.
getTranslatedMiddleName
(
**
kw
)
not
in
(
None
,
''
):
name_list
.
append
(
self
.
getTranslatedMiddleName
(
**
kw
))
if
self
.
getTranslatedLastName
(
**
kw
)
not
in
(
None
,
''
):
name_list
.
append
(
self
.
getTranslatedLastName
(
**
kw
))
return
' '
.
join
(
name_list
)
if
not
self
.
title
:
return
' '
.
join
([
x
for
x
in
(
self
.
getTranslatedFirstName
(
**
kw
),
self
.
getTranslatedMiddleName
(
**
kw
),
self
.
getTranslatedLastName
(
**
kw
))
if
x
])
else
:
return
self
.
title
...
...
@@ -136,26 +126,6 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
def
hasTitle
(
self
):
return
not
not
self
.
getTitle
()
def
_setFirstName
(
self
,
value
):
"""
Update Title if first_name is modified
"""
self
.
_baseSetFirstName
(
value
)
name_list
=
[]
if
self
.
getFirstName
():
name_list
.
append
(
self
.
getFirstName
())
if
self
.
getLastName
():
name_list
.
append
(
self
.
getLastName
())
if
name_list
:
self
.
_setTitle
(
' '
.
join
(
name_list
))
def
_setLastName
(
self
,
value
):
"""
Update Title if last_name is modified
"""
self
.
_baseSetLastName
(
value
)
name_list
=
[]
if
self
.
getFirstName
():
name_list
.
append
(
self
.
getFirstName
())
if
self
.
getLastName
():
name_list
.
append
(
self
.
getLastName
())
if
name_list
:
self
.
_setTitle
(
' '
.
join
(
name_list
))
def
_setReference
(
self
,
value
):
"""
Set the user id. This method is defined explicitly, because:
...
...
product/ERP5/tests/testPerson.py
View file @
2155dbf5
...
...
@@ -109,6 +109,8 @@ class TestPerson(ERP5TypeTestCase):
p
.
setFirstName
(
'first'
)
p
.
setLastName
(
'last'
)
self
.
assertEqual
(
'first last'
,
p
.
getTitle
())
p
.
setMiddleName
(
'middle'
)
self
.
assertEqual
(
'first middle last'
,
p
.
getTitle
())
def
testEditFirstNameLastName
(
self
):
# using 'edit' method
...
...
@@ -118,13 +120,19 @@ class TestPerson(ERP5TypeTestCase):
self
.
assertEqual
(
'first'
,
p
.
getFirstName
())
self
.
assertEqual
(
'last'
,
p
.
getLastName
())
self
.
assertEqual
(
'first last'
,
p
.
getTitle
())
self
.
assertEqual
(
'first last'
,
p
.
getTranslatedTitle
())
p
.
edit
(
middle_name
=
'middle'
)
self
.
assertEqual
(
'first middle last'
,
p
.
getTitle
())
self
.
assertEqual
(
'first middle last'
,
p
.
getTranslatedTitle
())
def
testEditTitleFirstNameLastName
(
self
):
p
=
self
.
_makeOne
(
id
=
'person'
)
p
.
edit
(
first_name
=
'first'
,
last_name
=
'last'
,
title
=
'title'
)
# no infinite loop :) but there's no guarantee on the behaviour
self
.
assertEqual
(
'title'
,
p
.
getTitle
())
p
.
edit
(
middle_name
=
'middle'
)
self
.
assertEqual
(
'title'
,
p
.
getTitle
())
def
testGetTitleOrId
(
self
):
p
=
self
.
_makeOne
(
id
=
'person'
)
...
...
@@ -136,6 +144,10 @@ class TestPerson(ERP5TypeTestCase):
self
.
assertEqual
(
'first last'
,
p
.
getTitleOrId
())
self
.
assertEqual
(
'first last'
,
p
.
title_or_id
())
p
.
edit
(
middle_name
=
'middle'
)
self
.
assertEqual
(
'first middle last'
,
p
.
getTitleOrId
())
self
.
assertEqual
(
'first middle last'
,
p
.
title_or_id
())
def
testHasTitle
(
self
):
p
=
self
.
_makeOne
(
id
=
'person'
)
self
.
assertFalse
(
p
.
hasTitle
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment