Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
549c999d06d2
Commit
1b4c0274
authored
Sep 11, 2013
by
Aurelien Campeas
Browse files
[editcontroller] fix cardinality computation (closes #3120495)
parent
5a4fba9a02d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
web/test/unittest_views_basecontrollers.py
View file @
549c999d
...
...
@@ -221,6 +221,21 @@ class EditControllerTC(CubicWebTC):
# created before.
self
.
assertGreater
(
salesterm
.
eid
,
salesterm
.
described_by_test
[
0
].
eid
)
def
test_edit_mandatory_inlined3_object
(
self
):
# non regression test for #3120495. Without the fix, leads to
# "unhashable type: 'list'" error
req
=
self
.
request
()
cwrelation
=
u
(
req
.
execute
(
'CWEType X WHERE X name "CWSource"'
)[
0
][
0
])
req
.
form
=
{
'eid'
:
[
cwrelation
],
'__maineid'
:
cwrelation
,
'__type:'
+
cwrelation
:
'CWEType'
,
'_cw_entity_fields:'
+
cwrelation
:
'to_entity-object'
,
'to_entity-object:'
+
cwrelation
:
[
9999
,
9998
],
}
with
self
.
session
.
deny_all_hooks_but
():
path
,
params
=
self
.
expect_redirect_handle_request
(
req
,
'edit'
)
self
.
assertTrue
(
path
.
startswith
(
'cwetype/CWSource'
),
path
)
def
test_edit_multiple_linked
(
self
):
req
=
self
.
request
()
peid
=
u
(
self
.
create_user
(
req
,
'adim'
).
eid
)
...
...
web/views/editcontroller.py
View file @
549c999d
...
...
@@ -158,7 +158,7 @@ class EditController(basecontrollers.ViewController):
# if cardinality is 1 and if the target entity is being
# simultaneously edited, the current entity must be
# created before the target one
if
rdef
.
cardinality
[
0
]
==
'1'
:
if
rdef
.
cardinality
[
0
if
role
==
'subject'
else
1
]
==
'1'
:
target_eid
=
values
[
param
]
if
target_eid
in
values_by_eid
:
# add dependency from the target entity to the
...
...
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