Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5_fork
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
erp5_fork
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
Show 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):
...
@@ -93,17 +93,12 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
def
getTitle
(
self
,
**
kw
):
def
getTitle
(
self
,
**
kw
):
"""
"""
Returns the title if it exists or a combination of
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
==
''
:
if
not
self
.
title
:
name_list
=
[]
return
' '
.
join
([
x
for
x
in
(
self
.
getFirstName
(),
if
self
.
getFirstName
()
not
in
(
None
,
''
):
self
.
getMiddleName
(),
name_list
.
append
(
self
.
getFirstName
())
self
.
getLastName
())
if
x
])
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
)
else
:
else
:
return
self
.
title
return
self
.
title
...
@@ -112,17 +107,12 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
...
@@ -112,17 +107,12 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
def
getTranslatedTitle
(
self
,
**
kw
):
def
getTranslatedTitle
(
self
,
**
kw
):
"""
"""
Returns the title if it exists or a combination of
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
==
''
:
if
not
self
.
title
:
name_list
=
[]
return
' '
.
join
([
x
for
x
in
(
self
.
getTranslatedFirstName
(
**
kw
),
if
self
.
getTranslatedFirstName
(
**
kw
)
not
in
(
None
,
''
):
self
.
getTranslatedMiddleName
(
**
kw
),
name_list
.
append
(
self
.
getTranslatedFirstName
(
**
kw
))
self
.
getTranslatedLastName
(
**
kw
))
if
x
])
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
)
else
:
else
:
return
self
.
title
return
self
.
title
...
@@ -136,26 +126,6 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
...
@@ -136,26 +126,6 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
def
hasTitle
(
self
):
def
hasTitle
(
self
):
return
not
not
self
.
getTitle
()
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
):
def
_setReference
(
self
,
value
):
"""
"""
Set the user id. This method is defined explicitly, because:
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):
...
@@ -109,6 +109,8 @@ class TestPerson(ERP5TypeTestCase):
p
.
setFirstName
(
'first'
)
p
.
setFirstName
(
'first'
)
p
.
setLastName
(
'last'
)
p
.
setLastName
(
'last'
)
self
.
assertEqual
(
'first last'
,
p
.
getTitle
())
self
.
assertEqual
(
'first last'
,
p
.
getTitle
())
p
.
setMiddleName
(
'middle'
)
self
.
assertEqual
(
'first middle last'
,
p
.
getTitle
())
def
testEditFirstNameLastName
(
self
):
def
testEditFirstNameLastName
(
self
):
# using 'edit' method
# using 'edit' method
...
@@ -118,13 +120,19 @@ class TestPerson(ERP5TypeTestCase):
...
@@ -118,13 +120,19 @@ class TestPerson(ERP5TypeTestCase):
self
.
assertEqual
(
'first'
,
p
.
getFirstName
())
self
.
assertEqual
(
'first'
,
p
.
getFirstName
())
self
.
assertEqual
(
'last'
,
p
.
getLastName
())
self
.
assertEqual
(
'last'
,
p
.
getLastName
())
self
.
assertEqual
(
'first last'
,
p
.
getTitle
())
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
):
def
testEditTitleFirstNameLastName
(
self
):
p
=
self
.
_makeOne
(
id
=
'person'
)
p
=
self
.
_makeOne
(
id
=
'person'
)
p
.
edit
(
first_name
=
'first'
,
p
.
edit
(
first_name
=
'first'
,
last_name
=
'last'
,
last_name
=
'last'
,
title
=
'title'
)
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
):
def
testGetTitleOrId
(
self
):
p
=
self
.
_makeOne
(
id
=
'person'
)
p
=
self
.
_makeOne
(
id
=
'person'
)
...
@@ -136,6 +144,10 @@ class TestPerson(ERP5TypeTestCase):
...
@@ -136,6 +144,10 @@ class TestPerson(ERP5TypeTestCase):
self
.
assertEqual
(
'first last'
,
p
.
getTitleOrId
())
self
.
assertEqual
(
'first last'
,
p
.
getTitleOrId
())
self
.
assertEqual
(
'first last'
,
p
.
title_or_id
())
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
):
def
testHasTitle
(
self
):
p
=
self
.
_makeOne
(
id
=
'person'
)
p
=
self
.
_makeOne
(
id
=
'person'
)
self
.
assertFalse
(
p
.
hasTitle
())
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