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
Paul Graydon
erp5
Commits
d9fb5f69
Commit
d9fb5f69
authored
Apr 26, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support domains in category accessors
parent
660662f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
9 deletions
+35
-9
product/ERP5/tests/testDomainTool.py
product/ERP5/tests/testDomainTool.py
+23
-0
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+12
-9
No files found.
product/ERP5/tests/testDomainTool.py
View file @
d9fb5f69
...
@@ -675,6 +675,29 @@ class TestDomainTool(TestPredicateMixIn):
...
@@ -675,6 +675,29 @@ class TestDomainTool(TestPredicateMixIn):
tested_base_category_list
=
[
'WAAA'
,
'BOOO'
],
tested_base_category_list
=
[
'WAAA'
,
'BOOO'
],
src__
=
1
))
src__
=
1
))
def
test_setRelationToBaseDomain
(
self
):
# category accessors can be useed to set relations to base domains.
base_domain
=
self
.
portal
.
portal_domains
.
newContent
(
portal_type
=
'Base Domain'
)
# get a document with source accessor
document
=
self
.
portal
.
sale_order_module
.
newContent
(
portal_type
=
'Sale Order'
)
document
.
setSourceValue
(
base_domain
)
self
.
assertEqual
(
base_domain
,
document
.
getSourceValue
())
def
test_setRelationToDomain
(
self
):
# category accessors can be useed to set relations to domains.
base_domain
=
self
.
portal
.
portal_domains
.
newContent
(
portal_type
=
'Base Domain'
)
domain
=
base_domain
.
newContent
(
portal_type
=
'Domain'
)
# get a document with source accessor
document
=
self
.
portal
.
sale_order_module
.
newContent
(
portal_type
=
'Sale Order'
)
document
.
setSourceValue
(
domain
)
self
.
assertEqual
(
domain
,
document
.
getSourceValue
())
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
...
...
product/ERP5Type/Base.py
View file @
d9fb5f69
...
@@ -1810,14 +1810,19 @@ class Base( CopyContainer,
...
@@ -1810,14 +1810,19 @@ class Base( CopyContainer,
# categories
# categories
def
_setValue
(
self
,
id
,
target
,
spec
=
(),
filter
=
None
,
portal_type
=
(),
keep_default
=
1
,
def
_setValue
(
self
,
id
,
target
,
spec
=
(),
filter
=
None
,
portal_type
=
(),
keep_default
=
1
,
checked_permission
=
None
):
checked_permission
=
None
):
start_string
=
"%s/"
%
id
getRelativeUrl
=
self
.
getPortalObject
().
portal_url
.
getRelativeUrl
start_string_len
=
len
(
start_string
)
def
cleanupCategory
(
path
):
# prevent duplicating base categories and storing "portal_categories/"
for
start_string
in
(
"%s/"
%
id
,
"portal_categories/"
):
if
path
.
startswith
(
start_string
):
path
=
path
[
len
(
start_string
):]
return
path
if
target
is
None
:
if
target
is
None
:
path
=
target
path
=
target
elif
isinstance
(
target
,
str
):
elif
isinstance
(
target
,
str
):
# We have been provided a string
# We have been provided a string
path
=
target
path
=
target
if
path
.
startswith
(
start_string
):
path
=
path
[
start_string_len
:]
# Prevent duplicating base category
elif
isinstance
(
target
,
(
tuple
,
list
,
set
,
frozenset
)):
elif
isinstance
(
target
,
(
tuple
,
list
,
set
,
frozenset
)):
# We have been provided a list or tuple
# We have been provided a list or tuple
path_list
=
[]
path_list
=
[]
...
@@ -1825,15 +1830,13 @@ class Base( CopyContainer,
...
@@ -1825,15 +1830,13 @@ class Base( CopyContainer,
if
isinstance
(
target_item
,
str
):
if
isinstance
(
target_item
,
str
):
path
=
target_item
path
=
target_item
else
:
else
:
path
=
target_item
.
getRelativeUrl
()
path
=
getRelativeUrl
(
target_item
)
if
path
.
startswith
(
start_string
):
path
=
path
[
start_string_len
:]
# Prevent duplicating base category
path_list
.
append
(
cleanupCategory
(
path
))
path_list
+=
[
path
]
path
=
path_list
path
=
path_list
else
:
else
:
# We have been provided an object
# We have been provided an object
# Find the object
path
=
cleanupCategory
(
getRelativeUrl
(
target
))
path
=
target
.
getRelativeUrl
()
if
path
.
startswith
(
start_string
):
path
=
path
[
start_string_len
:]
# Prevent duplicating base category
self
.
_setCategoryMembership
(
id
,
path
,
spec
=
spec
,
filter
=
filter
,
portal_type
=
portal_type
,
self
.
_setCategoryMembership
(
id
,
path
,
spec
=
spec
,
filter
=
filter
,
portal_type
=
portal_type
,
base
=
0
,
keep_default
=
keep_default
,
base
=
0
,
keep_default
=
keep_default
,
checked_permission
=
checked_permission
)
checked_permission
=
checked_permission
)
...
...
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