Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5-Boxiang
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
Hamza
erp5-Boxiang
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
Show 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):
...
@@ -96,11 +96,12 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
first name, middle name and last name
first name, middle name and last name
"""
"""
if
not
self
.
title
:
if
not
self
.
title
:
return
' '
.
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
])
else
:
if
title
:
return
self
.
title
return
title
return
super
(
Person
,
self
).
getTitle
(
**
kw
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getTranslatedTitle'
)
'getTranslatedTitle'
)
...
@@ -110,11 +111,12 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
...
@@ -110,11 +111,12 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
first name, middle name and last name
first name, middle name and last name
"""
"""
if
not
self
.
title
:
if
not
self
.
title
:
return
' '
.
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
])
else
:
if
title
:
return
self
.
title
return
title
return
super
(
Person
,
self
).
getTranslatedTitle
(
**
kw
)
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'title_or_id'
)
'title_or_id'
)
...
@@ -124,7 +126,10 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
...
@@ -124,7 +126,10 @@ class Person(Node, LoginAccountProviderMixin, EncryptedPasswordMixin):
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'hasTitle'
)
'hasTitle'
)
def
hasTitle
(
self
):
def
hasTitle
(
self
):
return
not
not
self
.
getTitle
()
return
self
.
hasFirstName
()
or
\
self
.
hasLastName
()
or
\
self
.
hasMiddleName
()
or
\
self
.
_baseHasTitle
()
def
_setReference
(
self
,
value
):
def
_setReference
(
self
,
value
):
"""
"""
...
...
product/ERP5/tests/testPerson.py
View file @
4e5e9a0f
...
@@ -90,9 +90,37 @@ class TestPerson(ERP5TypeTestCase):
...
@@ -90,9 +90,37 @@ class TestPerson(ERP5TypeTestCase):
self
.
assertEqual
(
person_copy_obj
.
getReference
(),
person
.
getReference
())
self
.
assertEqual
(
person_copy_obj
.
getReference
(),
person
.
getReference
())
# title & first_name, last_name
# title & first_name, last_name
def
testEmptyTitle
(
self
):
def
testEmptyTitleFallbackOnId
(
self
):
p
=
self
.
_makeOne
()
p
=
self
.
_makeOne
(
id
=
self
.
id
())
self
.
assertEqual
(
''
,
p
.
getTitle
())
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
):
def
testSetFirstName
(
self
):
p
=
self
.
_makeOne
()
p
=
self
.
_makeOne
()
...
@@ -112,6 +140,22 @@ class TestPerson(ERP5TypeTestCase):
...
@@ -112,6 +140,22 @@ class TestPerson(ERP5TypeTestCase):
p
.
setMiddleName
(
'middle'
)
p
.
setMiddleName
(
'middle'
)
self
.
assertEqual
(
'first middle last'
,
p
.
getTitle
())
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
):
def
testEditFirstNameLastName
(
self
):
# using 'edit' method
# using 'edit' method
p
=
self
.
_makeOne
(
id
=
'person'
)
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