Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
cb2a8f13
Verified
Commit
cb2a8f13
authored
6 months ago
by
Erwan Rouchet
Browse files
Options
Downloads
Patches
Plain Diff
Fix max orderings in CreateElementChildren
parent
1d1864cd
No related branches found
No related tags found
1 merge request
!2429
Fix max orderings in CreateElementChildren
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/documents/serializers/elements.py
+1
-0
1 addition, 0 deletions
arkindex/documents/serializers/elements.py
arkindex/documents/tests/test_bulk_children.py
+9
-3
9 additions, 3 deletions
arkindex/documents/tests/test_bulk_children.py
with
10 additions
and
3 deletions
arkindex/documents/serializers/elements.py
+
1
−
0
View file @
cb2a8f13
...
...
@@ -1006,6 +1006,7 @@ class ElementChildrenCreateSerializer(serializers.Serializer):
ElementPath
.
objects
.
using
(
"
default
"
)
.
filter
(
path__in
=
new_parent_paths
)
.
values
(
"
path
"
)
.
annotate
(
max_ordering
=
Max
(
"
ordering
"
)
+
1
)
.
values_list
(
"
path
"
,
"
max_ordering
"
)
)
...
...
This diff is collapsed.
Click to expand it.
arkindex/documents/tests/test_bulk_children.py
+
9
−
3
View file @
cb2a8f13
...
...
@@ -149,6 +149,8 @@ class TestElementChildrenCreate(FixtureAPITestCase):
other_parent
=
self
.
corpus
.
elements
.
create
(
type
=
self
.
volume2
.
type
,
name
=
"
Other parent
"
)
self
.
page2
.
add_parent
(
other_parent
)
self
.
page3
.
add_parent
(
other_parent
)
page4
=
self
.
corpus
.
elements
.
create
(
type
=
self
.
page3
.
type
,
name
=
"
Page 4
"
)
page4
.
add_parent
(
self
.
volume2
)
self
.
assertQuerySetEqual
(
self
.
volume2
.
paths
.
values_list
(
"
path
"
,
flat
=
True
),
...
...
@@ -170,6 +172,10 @@ class TestElementChildrenCreate(FixtureAPITestCase):
([
self
.
volume1
.
id
,
self
.
volume2
.
id
],
2
),
],
)
self
.
assertQuerySetEqual
(
page4
.
paths
.
values_list
(
"
path
"
,
"
ordering
"
),
[([
self
.
volume1
.
id
,
self
.
volume2
.
id
],
3
)],
)
with
force_constraints_immediate
(),
self
.
assertNumQueries
(
10
):
response
=
self
.
client
.
post
(
...
...
@@ -187,7 +193,7 @@ class TestElementChildrenCreate(FixtureAPITestCase):
self
.
assertQuerySetEqual
(
self
.
page1
.
paths
.
values_list
(
"
path
"
,
"
ordering
"
),
# The top-level path is removed, and the page is back in the volume, in last position
[([
self
.
volume1
.
id
,
self
.
volume2
.
id
],
5
)],
[([
self
.
volume1
.
id
,
self
.
volume2
.
id
],
6
)],
)
self
.
assertQuerySetEqual
(
self
.
page2
.
paths
.
values_list
(
"
path
"
,
"
ordering
"
).
order_by
(
"
ordering
"
),
...
...
@@ -195,7 +201,7 @@ class TestElementChildrenCreate(FixtureAPITestCase):
# The path to the other parent is left untouched
([
other_parent
.
id
],
0
),
# The page is back in the volume, in second position
([
self
.
volume1
.
id
,
self
.
volume2
.
id
],
4
),
([
self
.
volume1
.
id
,
self
.
volume2
.
id
],
5
),
],
)
self
.
assertQuerySetEqual
(
...
...
@@ -204,6 +210,6 @@ class TestElementChildrenCreate(FixtureAPITestCase):
# The path to the other parent is left untouched
([
other_parent
.
id
],
1
),
# The last page got reordered
([
self
.
volume1
.
id
,
self
.
volume2
.
id
],
3
),
([
self
.
volume1
.
id
,
self
.
volume2
.
id
],
4
),
],
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment