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
4ecd0229
Commit
4ecd0229
authored
4 years ago
by
Eva Bardou
Browse files
Options
Downloads
Patches
Plain Diff
Refactor selected elements deletion endpoint
parent
364d4ec1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/documents/api/elements.py
+0
-27
0 additions, 27 deletions
arkindex/documents/api/elements.py
arkindex/project/api_v1.py
+0
-4
0 additions, 4 deletions
arkindex/project/api_v1.py
with
0 additions
and
31 deletions
arkindex/documents/api/elements.py
+
0
−
27
View file @
4ecd0229
...
...
@@ -1170,32 +1170,6 @@ class ElementBulkCreate(CreateAPIView):
return
[{
'
id
'
:
element_data
[
'
element
'
].
id
}
for
element_data
in
elements
]
<<<<<<<
HEAD
class
CorpusDeleteSelection
(
SelectionMixin
,
DestroyAPIView
):
"""
Delete all selected elements on a corpus
"""
serializer_class
=
CorpusSerializer
openapi_overrides
=
{
'
operationId
'
:
'
DeleteCorpusSelection
'
,
'
tags
'
:
[
'
elements
'
]
}
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
rights
=
Corpus
.
objects
.
get
(
id
=
self
.
kwargs
[
'
pk
'
]).
get_acl_rights
(
request
.
user
)
if
Right
.
Admin
not
in
rights
:
self
.
permission_denied
(
request
,
message
=
'
You do not have admin access to delete elements on this corpus.
'
)
selected_elements
=
self
.
get_selection
(
corpus_id
=
self
.
kwargs
[
'
pk
'
])
if
not
selected_elements
.
exists
():
raise
NotFound
for
batch
in
range
(
0
,
selected_elements
.
count
(),
50
):
queryset
=
Element
.
objects
.
filter
(
id__in
=
list
(
selected_elements
[
batch
:
batch
+
50
].
values_list
(
'
id
'
,
flat
=
True
)))
element_trash
(
queryset
,
user_id
=
self
.
request
.
user
.
id
)
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
=======
class
CorpusDeleteSelection
(
ElementsListMixin
,
SelectionMixin
,
DestroyAPIView
):
"""
Delete selected elements on a corpus
...
...
@@ -1205,4 +1179,3 @@ class CorpusDeleteSelection(ElementsListMixin, SelectionMixin, DestroyAPIView):
# Should not be possible due to the URL
assert
self
.
selected_corpus
,
'
Missing corpus ID
'
return
self
.
get_selection
(
corpus_id
=
self
.
selected_corpus
.
id
)
>>>>>>>
Start
working
on
selected
elements
deletion
This diff is collapsed.
Click to expand it.
arkindex/project/api_v1.py
+
0
−
4
View file @
4ecd0229
...
...
@@ -145,11 +145,7 @@ api = [
path
(
'
corpus/<uuid:pk>/ml-stats/
'
,
CorpusMLStats
.
as_view
(),
name
=
'
corpus-ml-stats
'
),
path
(
'
corpus/<uuid:pk>/allowed-metadata/
'
,
CorpusAllowedMetaData
.
as_view
(),
name
=
'
corpus-allowed-metadata
'
),
path
(
'
corpus/<uuid:pk>/versions/
'
,
CorpusWorkerVersionList
.
as_view
(),
name
=
'
corpus-versions
'
),
<<<<<<<
HEAD
path
(
'
corpus/<uuid:pk>/selection/
'
,
CorpusDeleteSelection
.
as_view
(),
name
=
'
corpus-delete-selection
'
),
=======
path
(
'
corpus/<uuid:corpus>/selection/
'
,
CorpusDeleteSelection
.
as_view
(),
name
=
'
corpus-delete-selection
'
),
>>>>>>>
Start
working
on
selected
elements
deletion
# Moderation
path
(
'
ml-classes/
'
,
MLClassList
.
as_view
(),
name
=
'
mlclass-list
'
),
...
...
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