Skip to content
Snippets Groups Projects
Commit de12b60a authored by ml bonhomme's avatar ml bonhomme :bee: Committed by Bastien Abadie
Browse files

Apply review + require only Contributor access for non-delete endpoints +...

Apply review + require only Contributor access for non-delete endpoints + update Dataset endpoints documentation
parent 598da8ca
No related branches found
No related tags found
1 merge request!2267Dataset sets management API endpoints
This commit is part of merge request !2267. Comments created here will be created in the context of that merge request.
......@@ -657,11 +657,6 @@ class CorpusDataset(CorpusACLMixin, ListCreateAPIView):
"""
Update a dataset. The dataset must not be in `complete` state.
The sets array can only be updated following those cases:
* Adding or removing sets, nothing specific is done.
* Updating a single set within the array,
all elements linked to the previous set will be moved to the new one.
Requires a **contributor** access to the dataset's corpus.
"""
),
......@@ -671,11 +666,6 @@ class CorpusDataset(CorpusACLMixin, ListCreateAPIView):
"""
Partially update a dataset. The dataset must not be in `complete` state.
The sets array can only be updated following those cases:
* Adding or removing sets, nothing specific is done.
* Updating a single set within the array,
all elements linked to the previous set will be moved to the new one.
Requires a **contributor** access to the dataset's corpus.
"""
)
......@@ -761,8 +751,10 @@ class DatasetSetBase():
.select_related("corpus"),
pk=dataset_id
)
if dataset.corpus not in Corpus.objects.admin(self.request.user):
if self.request.method == "DELETE" and not Corpus.objects.admin(self.request.user).filter(pk=dataset.corpus_id).exists():
raise PermissionDenied(detail="You do not have admin access to this dataset.")
elif self.request.method != "DELETE" and not Corpus.objects.writable(self.request.user).filter(pk=dataset.corpus_id).exists():
raise PermissionDenied(detail="You do not have contributor access to this dataset.")
if dataset.state != DatasetState.Open:
raise ValidationError(detail="You can only add or update sets from a dataset in an open state.")
return dataset
......@@ -784,7 +776,7 @@ class DatasetSetBase():
"""
Sets can only be created in **open** datasets.
Requires **admin** access to the dataset's corpus.
Requires **contributor** access to the dataset's corpus.
"""
)
),
......@@ -814,7 +806,7 @@ class DatasetSetCreate(DatasetSetBase, CreateAPIView):
"""
Sets can only be updated if the dataset is in the **open** state.
Requires **admin** access to the dataset's corpus.
Requires **contributor** access to the dataset's corpus.
"""
)
),
......@@ -824,7 +816,7 @@ class DatasetSetCreate(DatasetSetBase, CreateAPIView):
"""
Sets can only be updated if the dataset is in the **open** state.
Requires **admin** access to the dataset's corpus.
Requires **contributor** access to the dataset's corpus.
"""
)
)
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment