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
Binh
erp5
Commits
e38f80f1
Commit
e38f80f1
authored
Feb 21, 2019
by
Kazuhiko Shiozaki
Committed by
Julien Muchembled
Sep 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CMFCategory: keep only the first occurrence of each category while preserving order.
parent
54b2d7a6
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
15 deletions
+24
-15
bt5/erp5_ui_test/PathTemplateItem/portal_tests/relation_field_zuite/testSimpleMultiRelationField.zpt
...sts/relation_field_zuite/testSimpleMultiRelationField.zpt
+3
-3
product/CMFCategory/CategoryTool.py
product/CMFCategory/CategoryTool.py
+3
-2
product/CMFCategory/tests/testCMFCategory.py
product/CMFCategory/tests/testCMFCategory.py
+12
-4
product/ERP5Type/tests/testERP5Type.py
product/ERP5Type/tests/testERP5Type.py
+6
-6
No files found.
bt5/erp5_ui_test/PathTemplateItem/portal_tests/relation_field_zuite/testSimpleMultiRelationField.zpt
View file @
e38f80f1
...
@@ -86,7 +86,7 @@ to set categories</td></tr>
...
@@ -86,7 +86,7 @@ to set categories</td></tr>
<tr>
<tr>
<td>
verifyValue
</td>
<td>
verifyValue
</td>
<td>
field_my_bar_category_title_list
</td>
<td>
field_my_bar_category_title_list
</td>
<td>
Title 0
<br
/>
Title 1
<
br
/>
Title 1
<
/td>
<td>
Title 0
<br
/>
Title 1
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<tr>
...
@@ -104,7 +104,7 @@ to set categories</td></tr>
...
@@ -104,7 +104,7 @@ to set categories</td></tr>
<tr>
<tr>
<td>
verifyValue
</td>
<td>
verifyValue
</td>
<td>
field_my_bar_category_title_list
</td>
<td>
field_my_bar_category_title_list
</td>
<td>
Title 0
<br
/>
Title 0
<br
/>
Title 1
<
br
/>
Title 1
<
/td>
<td>
Title 0
<br
/>
Title 0
<br
/>
Title 1
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<tr>
...
@@ -122,7 +122,7 @@ to set categories</td></tr>
...
@@ -122,7 +122,7 @@ to set categories</td></tr>
<tr>
<tr>
<td>
verifyValue
</td>
<td>
verifyValue
</td>
<td>
field_my_bar_category_title_list
</td>
<td>
field_my_bar_category_title_list
</td>
<td>
Title 1
<br
/>
Title 0
<
br
/>
Title 1
<
/td>
<td>
Title 1
<br
/>
Title 0
</td>
<td></td>
<td></td>
</tr>
</tr>
<!-- XXX don't test jump for now, because we don't have good locators anyway.
<!-- XXX don't test jump for now, because we don't have good locators anyway.
...
...
product/CMFCategory/CategoryTool.py
View file @
e38f80f1
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
"""
\
"""
\
ERP portal_categories tool.
ERP portal_categories tool.
"""
"""
from
collections
import
deque
from
collections
import
deque
,
OrderedDict
import
re
import
re
from
BTrees.OOBTree
import
OOTreeSet
from
BTrees.OOBTree
import
OOTreeSet
from
Products.ERP5Type.Globals
import
InitializeClass
,
DTMLFile
from
Products.ERP5Type.Globals
import
InitializeClass
,
DTMLFile
...
@@ -1189,7 +1189,8 @@ class CategoryTool(BaseTool):
...
@@ -1189,7 +1189,8 @@ class CategoryTool(BaseTool):
# note that we don't want to cast as set at this point to keep ordering (and duplicates).
# note that we don't want to cast as set at this point to keep ordering (and duplicates).
value
=
[
x
for
x
in
tuple
(
value
)
if
x
!=
relative_url
]
value
=
[
x
for
x
in
tuple
(
value
)
if
x
!=
relative_url
]
context
.
categories
=
value
=
tuple
(
value
)
# Keep only the first occurrence of each category while preserving order.
context
.
categories
=
value
=
tuple
(
OrderedDict
.
fromkeys
(
value
))
if
context
.
isTempDocument
():
if
context
.
isTempDocument
():
return
return
...
...
product/CMFCategory/tests/testCMFCategory.py
View file @
e38f80f1
...
@@ -221,6 +221,14 @@ class TestCMFCategory(ERP5TypeTestCase):
...
@@ -221,6 +221,14 @@ class TestCMFCategory(ERP5TypeTestCase):
p1
.
setRegionList
(
region_list
)
p1
.
setRegionList
(
region_list
)
self
.
assertEqual
(
p1
.
getRegion
(),
None
)
self
.
assertEqual
(
p1
.
getRegion
(),
None
)
region_list
=
[
self
.
region1
,
self
.
region2
,
self
.
region1
]
p1
.
setRegionList
(
region_list
)
self
.
assertEqual
(
p1
.
getRegionList
(),
self
.
region_list
)
p1
.
setRegionValueList
([
region_value_list
[
0
],
region_value_list
[
1
],
region_value_list
[
0
]])
self
.
assertEqual
(
p1
.
getRegionList
(),
self
.
region_list
)
def
test_03_CategoryValue
(
self
):
def
test_03_CategoryValue
(
self
):
# Test if we can get categories values
# Test if we can get categories values
region_value
=
self
.
portal
.
portal_categories
.
resolveCategory
(
'region/%s'
%
self
.
region1
)
region_value
=
self
.
portal
.
portal_categories
.
resolveCategory
(
'region/%s'
%
self
.
region1
)
...
@@ -1251,13 +1259,13 @@ class TestCMFCategory(ERP5TypeTestCase):
...
@@ -1251,13 +1259,13 @@ class TestCMFCategory(ERP5TypeTestCase):
def
_set
(
*
args
,
**
kw
):
def
_set
(
*
args
,
**
kw
):
return
category_tool
.
_setCategoryMembership
(
person
,
*
args
,
**
kw
)
return
category_tool
.
_setCategoryMembership
(
person
,
*
args
,
**
kw
)
_set
(
bc
.
id
,
list
(
'aa'
))
_set
(
bc
.
id
,
list
(
'aa'
))
self
.
assertEqual
(
get
(
bc
.
id
),
list
(
'a
a
'
))
self
.
assertEqual
(
get
(
bc
.
id
),
list
(
'a'
))
_set
(
bc
.
id
,
list
(
'baa'
))
_set
(
bc
.
id
,
list
(
'baa'
))
self
.
assertEqual
(
get
(
bc
.
id
),
list
(
'ab
a
'
))
self
.
assertEqual
(
get
(
bc
.
id
),
list
(
'ab'
))
_set
(
bc
.
id
,
map
(
base
,
'bb'
),
1
)
_set
(
bc
.
id
,
map
(
base
,
'bb'
),
1
)
self
.
assertEqual
(
get
(
bc
.
id
),
list
(
'b
b
'
))
self
.
assertEqual
(
get
(
bc
.
id
),
list
(
'b'
))
_set
(
bc
.
id
,
map
(
base
,
'abb'
),
1
)
_set
(
bc
.
id
,
map
(
base
,
'abb'
),
1
)
self
.
assertEqual
(
get
(
bc
.
id
),
list
(
'ba
b
'
))
self
.
assertEqual
(
get
(
bc
.
id
),
list
(
'ba'
))
_set
(
bc
.
id
,
())
_set
(
bc
.
id
,
())
def
test_relatedIndex
(
self
):
def
test_relatedIndex
(
self
):
...
...
product/ERP5Type/tests/testERP5Type.py
View file @
e38f80f1
...
@@ -639,12 +639,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -639,12 +639,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
person
.
setRegionValue
(
alpha
)
person
.
setRegionValue
(
alpha
)
self
.
assertEqual
(
person
.
getRegion
(),
'alpha'
)
self
.
assertEqual
(
person
.
getRegion
(),
'alpha'
)
person
.
setRegionValueList
([
alpha
,
alpha
])
person
.
setRegionValueList
([
alpha
,
alpha
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'alpha'
,
'alpha'
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'alpha'
])
person
.
setRegionValueSet
([
alpha
,
alpha
])
person
.
setRegionValueSet
([
alpha
,
alpha
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'alpha'
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'alpha'
])
self
.
assertEqual
(
person
.
getRegionSet
(),
[
'alpha'
])
self
.
assertEqual
(
person
.
getRegionSet
(),
[
'alpha'
])
person
.
setRegionValueList
([
alpha
,
beta
,
alpha
])
person
.
setRegionValueList
([
alpha
,
beta
,
alpha
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'alpha'
,
'beta'
,
'alpha'
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'alpha'
,
'beta'
])
person
.
setRegionValueSet
([
alpha
,
beta
,
alpha
])
person
.
setRegionValueSet
([
alpha
,
beta
,
alpha
])
result
=
person
.
getRegionSet
()
result
=
person
.
getRegionSet
()
result
.
sort
()
result
.
sort
()
...
@@ -677,12 +677,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -677,12 +677,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
person
.
setRegion
(
'alpha'
)
person
.
setRegion
(
'alpha'
)
self
.
assertEqual
(
person
.
getRegion
(),
'alpha'
)
self
.
assertEqual
(
person
.
getRegion
(),
'alpha'
)
person
.
setRegionList
([
'alpha'
,
'alpha'
])
person
.
setRegionList
([
'alpha'
,
'alpha'
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'alpha'
,
'alpha'
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'alpha'
])
self
.
assertEqual
(
person
.
getRegionSet
(),
[
'alpha'
])
self
.
assertEqual
(
person
.
getRegionSet
(),
[
'alpha'
])
person
.
setRegionSet
([
'beta'
,
'alpha'
,
'alpha'
])
person
.
setRegionSet
([
'beta'
,
'alpha'
,
'alpha'
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'alpha'
,
'beta'
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'alpha'
,
'beta'
])
person
.
setRegionList
([
'beta'
,
'alpha'
,
'alpha'
])
person
.
setRegionList
([
'beta'
,
'alpha'
,
'alpha'
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'beta'
,
'alpha'
,
'alpha'
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'beta'
,
'alpha'
])
# at this point the person have a default region set to the first item in
# at this point the person have a default region set to the first item in
# the list.
# the list.
self
.
assertEqual
(
person
.
getDefaultRegion
(),
'beta'
)
self
.
assertEqual
(
person
.
getDefaultRegion
(),
'beta'
)
...
@@ -717,11 +717,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -717,11 +717,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
person
.
setRegionUid
(
alpha
.
getUid
())
person
.
setRegionUid
(
alpha
.
getUid
())
self
.
assertEqual
(
person
.
getRegion
(),
'alpha'
)
self
.
assertEqual
(
person
.
getRegion
(),
'alpha'
)
person
.
setRegionUidList
([
beta
.
getUid
(),
beta
.
getUid
()])
person
.
setRegionUidList
([
beta
.
getUid
(),
beta
.
getUid
()])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'beta'
,
'beta'
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'beta'
])
person
.
setRegionUidSet
([
alpha
.
getUid
(),
alpha
.
getUid
()])
person
.
setRegionUidSet
([
alpha
.
getUid
(),
alpha
.
getUid
()])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'alpha'
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'alpha'
])
person
.
setRegionUidList
([
alpha
.
getUid
(),
beta
.
getUid
(),
alpha
.
getUid
()])
person
.
setRegionUidList
([
alpha
.
getUid
(),
beta
.
getUid
(),
alpha
.
getUid
()])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'alpha'
,
'beta'
,
'alpha'
])
self
.
assertEqual
(
person
.
getRegionList
(),
[
'alpha'
,
'beta'
])
person
.
setRegionUidSet
([
alpha
.
getUid
(),
beta
.
getUid
(),
alpha
.
getUid
()])
person
.
setRegionUidSet
([
alpha
.
getUid
(),
beta
.
getUid
(),
alpha
.
getUid
()])
self
.
assertEqual
(
sorted
(
person
.
getRegionSet
()),
[
'alpha'
,
'beta'
])
self
.
assertEqual
(
sorted
(
person
.
getRegionSet
()),
[
'alpha'
,
'beta'
])
person
.
setDefaultRegionUid
(
beta
.
getUid
())
person
.
setDefaultRegionUid
(
beta
.
getUid
())
...
...
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