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
f0543742
Verified
Commit
f0543742
authored
1 year ago
by
Erwan Rouchet
Browse files
Options
Downloads
Patches
Plain Diff
Restore set_elements on update responses
parent
6cafe501
No related branches found
No related tags found
1 merge request
!2256
New DatasetSet model
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex/training/api.py
+11
-0
11 additions, 0 deletions
arkindex/training/api.py
with
11 additions
and
0 deletions
arkindex/training/api.py
+
11
−
0
View file @
f0543742
...
...
@@ -716,6 +716,17 @@ class DatasetUpdate(ACLMixin, RetrieveUpdateDestroyAPIView):
if
obj
.
state
==
DatasetState
.
Complete
:
raise
ValidationError
(
detail
=
"
This dataset is in complete state and cannot be modified anymore.
"
)
def
update
(
self
,
request
,
*
args
,
**
kwargs
):
# Do exactly the same thing as what DRF does, but without the automatic prefetch cache removal:
# https://github.com/encode/django-rest-framework/blob/2da473c8c8e024e80c13a624782f1da6272812da/rest_framework/mixins.py#L70
# This allows `set_elements` to still be returned after the update.
partial
=
kwargs
.
pop
(
"
partial
"
,
False
)
instance
=
self
.
get_object
()
serializer
=
self
.
get_serializer
(
instance
,
data
=
request
.
data
,
partial
=
partial
)
serializer
.
is_valid
(
raise_exception
=
True
)
self
.
perform_update
(
serializer
)
return
Response
(
serializer
.
data
)
def
perform_destroy
(
self
,
dataset
):
DatasetElement
.
objects
.
filter
(
set__dataset_id
=
dataset
.
id
).
delete
()
dataset
.
sets
.
all
().
delete
()
...
...
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