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
Alain Takoudjou
erp5
Commits
03c92f96
Commit
03c92f96
authored
May 20, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
c7cb5665
A set setter keeps the default value, so in a sense the order is preserved.
parent
b57a5d20
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
product/ERP5Type/Accessor/Category.py
product/ERP5Type/Accessor/Category.py
+8
-1
product/ERP5Type/tests/testERP5Type.py
product/ERP5Type/tests/testERP5Type.py
+7
-1
No files found.
product/ERP5Type/Accessor/Category.py
View file @
03c92f96
...
@@ -100,7 +100,14 @@ class SetSetter(ListSetter):
...
@@ -100,7 +100,14 @@ class SetSetter(ListSetter):
"""
"""
if
type
(
value
)
not
in
(
set
,
frozenset
):
if
type
(
value
)
not
in
(
set
,
frozenset
):
value
=
frozenset
(
value
)
value
=
frozenset
(
value
)
return
ListSetter
.
__call__
(
self
,
instance
,
value
,
*
args
,
**
kw
)
instance
.
_setCategoryMembership
(
self
.
_key
,
value
,
spec
=
kw
.
get
(
'spec'
,()),
filter
=
kw
.
get
(
'filter'
,
None
),
portal_type
=
kw
.
get
(
'portal_type'
,()),
base
=
kw
.
get
(
'base'
,
0
),
keep_default
=
1
,
checked_permission
=
kw
.
get
(
'checked_permission'
,
None
))
return
(
instance
,
)
class
DefaultGetter
(
BaseGetter
):
class
DefaultGetter
(
BaseGetter
):
...
...
product/ERP5Type/tests/testERP5Type.py
View file @
03c92f96
...
@@ -700,8 +700,14 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -700,8 +700,14 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self
.
assertEquals
(
person
.
getRegionList
(),
[
'alpha'
,
'beta'
])
self
.
assertEquals
(
person
.
getRegionList
(),
[
'alpha'
,
'beta'
])
person
.
setRegionList
([
'beta'
,
'alpha'
,
'alpha'
])
person
.
setRegionList
([
'beta'
,
'alpha'
,
'alpha'
])
self
.
assertEquals
(
person
.
getRegionList
(),
[
'beta'
,
'alpha'
,
'alpha'
])
self
.
assertEquals
(
person
.
getRegionList
(),
[
'beta'
,
'alpha'
,
'alpha'
])
# at this point the person have a default region set to the first item in
# the list.
self
.
assertEquals
(
person
.
getDefaultRegion
(),
'beta'
)
person
.
setRegionSet
([
'alpha'
,
'beta'
,
'alpha'
])
person
.
setRegionSet
([
'alpha'
,
'beta'
,
'alpha'
])
self
.
assertEquals
(
sorted
(
person
.
getRegionList
()),
[
'alpha'
,
'beta'
])
self
.
assertEquals
(
person
.
getRegionList
(),
[
'beta'
,
'alpha'
])
# calling a set setter did not change the default region
self
.
assertEquals
(
person
.
getDefaultRegion
(),
'beta'
)
person
.
setDefaultRegion
(
'alpha'
)
person
.
setDefaultRegion
(
'alpha'
)
self
.
assertEquals
(
person
.
getDefaultRegion
(),
'alpha'
)
self
.
assertEquals
(
person
.
getDefaultRegion
(),
'alpha'
)
self
.
assertEquals
(
sorted
(
person
.
getRegionSet
()),
[
'alpha'
,
'beta'
])
self
.
assertEquals
(
sorted
(
person
.
getRegionSet
()),
[
'alpha'
,
'beta'
])
...
...
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