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
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
Sebastian
erp5
Commits
2889c4bd
Commit
2889c4bd
authored
Nov 17, 2014
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly cleanup path for category setter
parent
e62b1932
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
product/CMFCategory/tests/testCMFCategory.py
product/CMFCategory/tests/testCMFCategory.py
+18
-0
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+2
-1
No files found.
product/CMFCategory/tests/testCMFCategory.py
View file @
2889c4bd
...
...
@@ -1148,6 +1148,24 @@ class TestCMFCategory(ERP5TypeTestCase):
self
.
assertEqual
(
list
(
related
),
[
person
.
getRelativeUrl
()])
person
.
_setTest1Value
(
a
)
self
.
assertEqual
(
list
(
related
),
[])
def
test_Category_setCategoryValue
(
self
):
# Test all case of setting categories values
region_value
=
self
.
portal
.
portal_categories
.
resolveCategory
(
'region/europe'
)
region_value2
=
self
.
portal
.
portal_categories
.
resolveCategory
(
'region/europe/west'
)
self
.
assertNotEqual
(
None
,
region_value
)
self
.
assertNotEqual
(
None
,
region_value2
)
p1
=
self
.
getPersonModule
().
_getOb
(
self
.
id1
)
p1
.
setRegionValue
(
region_value
)
person
=
self
.
getPersonModule
().
newContent
(
region_value
=
region_value2
)
self
.
tic
()
self
.
assertEqual
(
p1
.
getRegion
(),
'europe'
)
self
.
assertTrue
(
'region/europe'
in
p1
.
getCategoryList
())
self
.
assertEqual
(
person
.
getRegion
(),
'europe/west'
)
self
.
assertTrue
(
'region/europe/west'
in
person
.
getCategoryList
())
def
test_suite
():
...
...
product/ERP5Type/Base.py
View file @
2889c4bd
...
...
@@ -1818,9 +1818,10 @@ class Base( CopyContainer,
def
_setValue
(
self
,
id
,
target
,
spec
=
(),
filter
=
None
,
portal_type
=
(),
keep_default
=
1
,
checked_permission
=
None
):
getRelativeUrl
=
self
.
getPortalObject
().
portal_url
.
getRelativeUrl
def
cleanupCategory
(
path
):
# prevent duplicating base categories and storing "portal_categories/"
for
start_string
in
(
"%s/"
%
id
,
"portal_categories/"
):
for
start_string
in
(
"portal_categories/"
,
"%s/"
%
id
):
if
path
.
startswith
(
start_string
):
path
=
path
[
len
(
start_string
):]
return
path
...
...
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