Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5_rtl_support
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
Romain Courteaud
erp5_rtl_support
Commits
4e5e9a0f
Commit
4e5e9a0f
authored
Mar 15, 2016
by
Jérome Perrin
Committed by
Tristan Cavelier
Apr 12, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5: make Person.getTitle fallback consistent with Base
when no title, fallback to reference then id
parent
4b275002
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
14 deletions
+63
-14
product/ERP5/Document/Person.py
product/ERP5/Document/Person.py
+16
-11
product/ERP5/tests/testPerson.py
product/ERP5/tests/testPerson.py
+47
-3
No files found.
product/ERP5/Document/Person.py
View file @
4e5e9a0f
...
...
@@ -96,11 +96,12 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
first name, middle name and last name
"""
if
not
self
.
title
:
return
' '
.
join
([
x
for
x
in
(
self
.
getFirstName
(),
self
.
getMiddleName
(),
self
.
getLastName
())
if
x
])
else
:
return
self
.
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
,
'getTranslatedTitle'
)
...
...
@@ -110,11 +111,12 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
first name, middle name and last name
"""
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
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
,
'title_or_id'
)
...
...
@@ -124,7 +126,10 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'hasTitle'
)
def
hasTitle
(
self
):
return
not
not
self
.
getTitle
()
return
self
.
hasFirstName
()
or
\
self
.
hasLastName
()
or
\
self
.
hasMiddleName
()
or
\
self
.
_baseHasTitle
()
def
_setReference
(
self
,
value
):
"""
...
...
product/ERP5/tests/testPerson.py
View file @
4e5e9a0f
...
...
@@ -90,9 +90,37 @@ class TestPerson(ERP5TypeTestCase):
self
.
assertEqual
(
person_copy_obj
.
getReference
(),
person
.
getReference
())
# title & first_name, last_name
def
testEmptyTitle
(
self
):
p
=
self
.
_makeOne
()
self
.
assertEqual
(
''
,
p
.
getTitle
())
def
testEmptyTitleFallbackOnId
(
self
):
p
=
self
.
_makeOne
(
id
=
self
.
id
())
self
.
assertEqual
(
self
.
id
(),
p
.
getTitle
())
def
testEmptyTranslatedTitleFallbackOnId
(
self
):
p
=
self
.
_makeOne
(
id
=
self
.
id
())
self
.
assertEqual
(
self
.
id
(),
p
.
getTranslatedTitle
())
def
testEmptyCompactTitleFallbackOnId
(
self
):
p
=
self
.
_makeOne
(
id
=
self
.
id
())
self
.
assertEqual
(
self
.
id
(),
p
.
getCompactTitle
())
def
testEmptyCompactTranslatedTitleFallbackOnId
(
self
):
p
=
self
.
_makeOne
(
id
=
self
.
id
())
self
.
assertEqual
(
self
.
id
(),
p
.
getCompactTranslatedTitle
())
def
testEmptyTitleFallbackOnReference
(
self
):
p
=
self
.
_makeOne
(
reference
=
'reference'
)
self
.
assertEqual
(
'reference'
,
p
.
getTitle
())
def
testEmptyTranslatedTitleFallbackOnReference
(
self
):
p
=
self
.
_makeOne
(
reference
=
'reference'
)
self
.
assertEqual
(
'reference'
,
p
.
getTranslatedTitle
())
def
testEmptyCompactTitleFallbackOnReference
(
self
):
p
=
self
.
_makeOne
(
reference
=
'reference'
)
self
.
assertEqual
(
'reference'
,
p
.
getCompactTitle
())
def
testEmptyCompactTranslatedTitleFallbackOnReference
(
self
):
p
=
self
.
_makeOne
(
reference
=
'reference'
)
self
.
assertEqual
(
'reference'
,
p
.
getCompactTranslatedTitle
())
def
testSetFirstName
(
self
):
p
=
self
.
_makeOne
()
...
...
@@ -112,6 +140,22 @@ class TestPerson(ERP5TypeTestCase):
p
.
setMiddleName
(
'middle'
)
self
.
assertEqual
(
'first middle last'
,
p
.
getTitle
())
def
testTranslatedTitleFromFirstLastName
(
self
):
p
=
self
.
_makeOne
(
id
=
'person'
)
p
.
setFirstName
(
'first'
)
p
.
setLastName
(
'last'
)
self
.
assertEqual
(
'first last'
,
p
.
getTranslatedTitle
())
p
.
setMiddleName
(
'middle'
)
self
.
assertEqual
(
'first middle last'
,
p
.
getTranslatedTitle
())
def
testCompactTranslatedTitleFromFirstLastName
(
self
):
p
=
self
.
_makeOne
(
id
=
'person'
)
p
.
setFirstName
(
'first'
)
p
.
setLastName
(
'last'
)
self
.
assertEqual
(
'first last'
,
p
.
getCompactTranslatedTitle
())
p
.
setMiddleName
(
'middle'
)
self
.
assertEqual
(
'first middle last'
,
p
.
getCompactTranslatedTitle
())
def
testEditFirstNameLastName
(
self
):
# using 'edit' method
p
=
self
.
_makeOne
(
id
=
'person'
)
...
...
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